<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><script>(()=>{const e=navigator.serviceWorker;e?e.register("/sw.js").then((async e=>{console.log("SWPP 注册成功");try{await e.periodicSync.register("update",{minInterval:864e5})}catch(e){console.log("Periodic Sync 注册失败",e)}})).catch((e=>console.error("SWPP 注册失败",e))):console.warn("当前浏览器不支持 SW")})()</script><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover"><title>Github Action实现友链状态检测 | LiuShen's Blog</title><meta name="author" content="LiuShen"><meta name="copyright" content="LiuShen"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="robots" content="index, follow"><meta name="description" content="随着友情链接数量的增加，人工检测变得繁琐，我最初尝试通过爬取数据进行检测，但数据更新滞后。在群友安小歪的启发下，我采用了GitHub Action自动运行检测脚本，比较有效实现了友链有效性的自动化监测，同时将数据展示在了友情链接页面中，除此之外，原有的摸鱼页面也被我整合到了友链朋友圈页面中。"><meta property="og:type" content="article"><meta property="og:title" content="Github Action实现友链状态检测"><meta property="og:url" content="https://blog.liushen.fun/posts/c2262998/"><meta property="og:site_name" content="LiuShen's Blog"><meta property="og:description" content="随着友情链接数量的增加，人工检测变得繁琐，我最初尝试通过爬取数据进行检测，但数据更新滞后。在群友安小歪的启发下，我采用了GitHub Action自动运行检测脚本，比较有效实现了友链有效性的自动化监测，同时将数据展示在了友情链接页面中，除此之外，原有的摸鱼页面也被我整合到了友链朋友圈页面中。"><meta property="og:locale" content="zh_CN"><meta property="og:image" content="https://p.liiiu.cn/i/2024/06/23/6676f5b705711.webp"><meta property="article:published_time" content="2024-06-23T17:00:00.000Z"><meta property="article:modified_time" content="2024-09-20T01:00:00.000Z"><meta property="article:author" content="LiuShen"><meta property="article:tag" content="Hexo"><meta property="article:tag" content="状态检测"><meta name="twitter:card" content="summary"><meta name="twitter:image" content="https://p.liiiu.cn/i/2024/06/23/6676f5b705711.webp"><link rel="shortcut icon" href="/favicon.ico"><link rel="canonical" href="https://blog.liushen.fun/posts/c2262998/"><link rel="preconnect" href="https://jsd.liiiu.cn"><meta name="baidu-site-verification" content="codeva-i2bF9bXDJs"><meta name="sogou_site_verification" content="1rIjtK6RhE"><meta name="360-site-verification" content="b9a9f96ae38a1932a326f8ba255cc74b"><meta name="msvalidate.01" content="F7C246820EB04DD140494C98F93A97C7"><meta name="google-site-verification" content="VH3ZE6m42MZDqpTY2tD-XoxDt9iUj2HoiC3W2neB7F4"><link rel="manifest" href="/manifest.json"><link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png"><link rel="icon" type="image/png" sizes="32x32" href="/config/img/pwa/favicon-32x32.png"><link rel="icon" type="image/png" sizes="16x16" href="/config/img/pwa/favicon-16x16.png"><link rel="mask-icon" href="/config/img/pwa/favicon-mask.svg" color="#5bbad5"><link rel="stylesheet" href="/css/index.css?v=5.0.0"><link rel="stylesheet" href="/css/custom.css?v=5.0.0"><link rel="stylesheet" href="https://jsd.liiiu.cn/npm/@fortawesome/fontawesome-free@6.7.2/css/all.min.css"><link rel="stylesheet" href="https://jsd.liiiu.cn/npm/@fancyapps/ui@5.0.36/dist/fancybox/fancybox.min.css" media="print" onload='this.media="all"'><script>(()=>{const e={set:(e,t,o)=>{if(!o)return;const n=Date.now()+864e5*o;localStorage.setItem(e,JSON.stringify({value:t,expiry:n}))},get:e=>{const t=localStorage.getItem(e);if(!t)return;const{value:o,expiry:n}=JSON.parse(t);if(!(Date.now()>n))return o;localStorage.removeItem(e)}};window.btf={saveToLocal:e,getScript:(e,t={})=>new Promise(((o,n)=>{const a=document.createElement("script");a.src=e,a.async=!0,Object.entries(t).forEach((([e,t])=>a.setAttribute(e,t))),a.onload=a.onreadystatechange=()=>{a.readyState&&!/loaded|complete/.test(a.readyState)||o()},a.onerror=n,document.head.appendChild(a)})),getCSS:(e,t)=>new Promise(((o,n)=>{const a=document.createElement("link");a.rel="stylesheet",a.href=e,t&&(a.id=t),a.onload=a.onreadystatechange=()=>{a.readyState&&!/loaded|complete/.test(a.readyState)||o()},a.onerror=n,document.head.appendChild(a)})),addGlobalFn:(e,t,o=!1,n=window)=>{const a=n.globalFn||{};a[e]=a[e]||{},o&&a[e][o]||(a[e][o||Object.keys(a[e]).length]=t,n.globalFn=a)}};const t=()=>{document.documentElement.setAttribute("data-theme","dark"),null!==document.querySelector('meta[name="theme-color"]')&&document.querySelector('meta[name="theme-color"]').setAttribute("content","#0d0d0d")},o=()=>{document.documentElement.setAttribute("data-theme","light"),null!==document.querySelector('meta[name="theme-color"]')&&document.querySelector('meta[name="theme-color"]').setAttribute("content","#ffffff")};btf.activateDarkMode=t,btf.activateLightMode=o;const n=e.get("theme"),a=(new Date).getHours();void 0===n?a<=6||a>=18?t():o():"light"===n?o():t();const r=e.get("aside-status");void 0!==r&&document.documentElement.classList.toggle("hide-aside","hide"===r);/iPad|iPhone|iPod|Macintosh/.test(navigator.userAgent)&&document.documentElement.classList.add("apple")})()</script><script>const GLOBAL_CONFIG={root:"/",algolia:{appId:"7IX3UBC6JW",apiKey:"4ac2846352e499675081f1277fb961c1",indexName:"My Blog",hitsPerPage:6,languages:{input_placeholder:"搜索全站文章",hits_empty:"未找到符合您查询的内容：${query}",hits_stats:"找到 ${hits} 条结果，耗时 ${time} 毫秒"}},localSearch:void 0,translate:{defaultEncoding:2,translateDelay:0,msgToTraditionalChinese:"繁",msgToSimplifiedChinese:"簡"},noticeOutdate:{limitDay:365,position:"top",messagePrev:"本篇文章从发布到现在已经隔了",messageNext:"天了，里面的内容可能过期了，你要自己甄别一下哟👉👈"},highlight:{plugin:"highlight.js",highlightCopy:!0,highlightLang:!0,highlightHeightLimit:400,highlightFullpage:!1,highlightMacStyle:!0},copy:{success:"😋复制啦！请注意版权信息呀！",error:"😪呜呜，复制失败了！",noSupport:"🤐浏览器不支持呢，你用的啥玩意？"},relativeDate:{homepage:!1,post:!1},runtime:"天",dateSuffix:{just:"刚刚",min:"分钟前",hour:"小时前",day:"天前",month:"个月前"},copyright:{limitCount:1e3,languages:{author:"作者: LiuShen",link:"链接: ",source:"来源: LiuShen's Blog",info:"著作权归作者所有。商业转载请联系作者获得授权，非商业转载请注明出处。"}},lightbox:"fancybox",Snackbar:{chs_to_cht:"已切换为繁体中文",cht_to_chs:"已切换为简体中文",day_to_night:"已切换为深色模式",night_to_day:"已切换为浅色模式",bgLight:"rgba(255, 255, 255, 0.509)",bgDark:"rgba(48, 48, 48, 0.509)",position:"top-right"},infinitegrid:{js:"https://jsd.liiiu.cn/npm/@egjs/infinitegrid@4.12.0/dist/infinitegrid.min.js",buttonText:"加载更多"},isPhotoFigcaption:!0,islazyload:!0,isAnchor:!1,percent:{toc:!0,rightside:!1},autoDarkmode:!1}</script><script id="config-diff">var GLOBAL_CONFIG_SITE={title:"Github Action实现友链状态检测",isPost:!0,isHome:!1,isHighlightShrink:void 0,isToc:!0,postUpdate:"2024-09-20 09:00:00"}</script><link rel="stylesheet" href="https://jsd.liiiu.cn/gh/willow-god/Sharding-fonts/Yozai-Medium/result.min.css"><link rel="stylesheet" href="/config/memos/memos.css"><script defer src="/sw-dom.js"></script><link rel="stylesheet" href="https://jsd.liiiu.cn/npm/swiper@11.1.14/swiper-bundle.min.css" media="print" onload='this.media="all"'><link rel="stylesheet" href="/config/swiper/swiperstyle.css" media="print" onload='this.media="all"'><meta name="generator" content="Hexo 7.3.0"><link rel="alternate" href="/atom.xml" title="LiuShen's Blog" type="application/atom+xml"></head><body><div class="float-box right top"></div><div id="loading-box"><div class="loading-left-bg"></div><div class="loading-right-bg"></div><img class="load-image" src="" data-lazy-src="/config/img/preloader.gif" alt=""></div><script async>(()=>{const e=document.getElementById("loading-box"),d=document.body,t=()=>{d.style.overflow="",e.classList.add("loaded")},n=()=>{d.style.overflow="hidden",e.classList.remove("loaded")};n();let o=!1;window.addEventListener("load",(()=>{o||(t(),o=!0)})),setTimeout((()=>{o||(t(),o=!0)}),5e3),window.addEventListener("load",(()=>{t()})),setTimeout((function(){t()}),3e3),document.getElementById("loading-box").addEventListener("click",(()=>{t()})),document.addEventListener("pjax:send",(()=>{n()})),document.addEventListener("pjax:complete",(()=>{t()}))})()</script><div id="web_bg"></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="add-menu-container"><div id="travellings"><a class="site-page" href="https://www.travellings.cn/go.html" title="友链接力-随机开往" target="_blank" rel="noopener nofollow"><i class="fa-solid fa-bus fa-fw"></i></a></div><div id="ten-years"><a class="site-page" href="https://foreverblog.cn/go.html" title="友链接力-十年之约" target="_blank" rel="noopener nofollow"><i class="fa-brands fa-nfc-symbol fa-fw"></i></a></div></div><div class="is-center" id="sidebar-avatar"><div class="avatar-img is-center"><img class="mood-icon" src="" data-lazy-src="https://p.liiiu.cn/i/2025/03/14/67d301461a24a.webp" alt="🤤" onerror='this.onerror=null,this.src="/img/friend_404.gif"'><img src="" data-lazy-src="https://p.liiiu.cn/i/2025/03/13/67d2fc82d329c.webp" onerror='this.onerror=null,this.src="/img/friend_404.gif"' alt="avatar"></div><div class="author-info__name">LiuShen</div></div><div class="site-data is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">72</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">98</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">3</div></a></div><a class="button--animated" id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/willow-god"><i class="fab fa-github"></i><span>Follow Me 🛫</span></a><div class="menus_items visible"><div class="menus_item"><span class="site-page group hide"><i class="fa-fw fas fa-home"></i> <span>导航</span><i class="fas fa-chevron-down"></i></span><ul class="menus_item_child"><li><a class="site-page child" target="_blank" rel="noopener" href="https://www.liushen.fun/"><i class="fa-fw fa-solid fa-house-flag"></i> <span>个人主页</span></a></li><li><a class="site-page child" target="_blank" rel="noopener" href="https://xc.liushen.fun/"><i class="fa-fw fa fa-camera-retro"></i> <span>个人相册</span></a></li></ul></div><div class="menus_item"><span class="site-page group hide"><i class="fa-fw fa fa-graduation-cap"></i> <span>整理</span><i class="fas fa-chevron-down"></i></span><ul class="menus_item_child"><li><a class="site-page child" href="/archives/"><i class="fa-fw fas fa-archive"></i> <span>时光卷轴</span></a></li><li><a class="site-page child" href="/tags/"><i class="fa-fw fas fa-tags"></i> <span>文章标签</span></a></li><li><a class="site-page child" href="/categories/"><i class="fa-fw fas fa-folder-open"></i> <span>文章分类</span></a></li><li><a class="site-page child" href="/charts/"><i class="fa-fw fa-solid fa-chart-pie"></i> <span>文章通览</span></a></li></ul></div><div class="menus_item"><span class="site-page group hide"><i class="fa-fw fa-solid fa-user-group"></i> <span>友人</span><i class="fas fa-chevron-down"></i></span><ul class="menus_item_child"><li><a class="site-page child" href="/link/"><i class="fa-fw fas fa-link"></i> <span>友链展示</span></a></li><li><a class="site-page child" href="/addlink/"><i class="fa-fw fa fa-at"></i> <span>友链申请</span></a></li><li><a class="site-page child" href="/fcircle/"><i class="fa-fw fa-solid fa-circle-nodes"></i> <span>朋友动态</span></a></li></ul></div><div class="menus_item"><span class="site-page group hide"><i class="fa-fw fa fa-paper-plane"></i> <span>留言</span><i class="fas fa-chevron-down"></i></span><ul class="menus_item_child"><li><a class="site-page child" href="/comment/"><i class="fa-fw fa-solid fa-chalkboard"></i> <span>留言白板</span></a></li><li><a class="site-page child" target="_blank" rel="noopener" href="https://mm.liushen.fun/"><i class="fa-fw fa-solid fa-pen-nib"></i> <span>提笔摘星</span></a></li></ul></div><div class="menus_item"><span class="site-page group hide"><i class="fa-fw fa-solid fa-stethoscope"></i> <span>分享</span><i class="fas fa-chevron-down"></i></span><ul class="menus_item_child"><li><a class="site-page child" target="_blank" rel="noopener" href="https://gist.liushen.fun/"><i class="fa-fw fa-solid fa-code"></i> <span>代码片段</span></a></li><li><a class="site-page child" href="/subscribe/"><i class="fa-fw fa-solid fa-rss"></i> <span>订阅本站</span></a></li><li><a class="site-page child" target="_blank" rel="noopener" href="https://pan.liushen.fun/"><i class="fa-fw fa-solid fa-laptop-file"></i> <span>清羽云盘</span></a></li></ul></div><div class="menus_item"><span class="site-page group hide"><i class="fa-fw fa fa-list"></i> <span>关于</span><i class="fas fa-chevron-down"></i></span><ul class="menus_item_child"><li><a class="site-page child" href="/about/"><i class="fa-fw fa fa-address-card"></i> <span>站长资料</span></a></li><li><a class="site-page child" href="/shuoshuo/"><i class="fa-fw fa fa-commenting"></i> <span>日常说说</span></a></li><li><a class="site-page child" href="/devices/"><i class="fa-fw fa-solid fa-tachograph-digital"></i> <span>我的设备</span></a></li></ul></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg fixed" id="page-header" style="background-image:url(https://p.liiiu.cn/i/2024/06/23/6676f5b705711.webp)"><nav id="nav"><div class="more-app-btn"><i class="fa-solid fa-fingerprint fa-fw"></i><div class="more-app-list-groups"><div class="more-app-list-groups-container"><div class="more-app-list-group"><div class="more-app-list-title">🦄常用网站</div><div class="more-app-list"><a class="more-app-list-item" href="https://www.liushen.fun/" rel="nofollow noopener" target="_blank"><i class="more-app-item-icon fa-solid fa-house"></i><span class="more-app-item-text">个人主页</span></a><a class="more-app-list-item" href="https://blog.liushen.fun/" rel="nofollow noopener" target="_blank"><i class="more-app-item-icon fa-solid fa-blog"></i><span class="more-app-item-text">个人博客</span></a><a class="more-app-list-item" href="https://xc.liushen.fun/" rel="nofollow noopener" target="_blank"><i class="more-app-item-icon fa-solid fa-image"></i><span class="more-app-item-text">个人相册</span></a><a class="more-app-list-item" href="https://github.com/willow-god" rel="nofollow noopener" target="_blank"><i class="more-app-item-icon fa-brands fa-github"></i><span class="more-app-item-text">Github</span></a></div></div><div class="more-app-list-group"><div class="more-app-list-title">😎周边站点</div><div class="more-app-list"><a class="more-app-list-item" href="https://gist.liushen.fun/" rel="nofollow noopener" target="_blank"><i class="more-app-item-icon fa-solid fa-code"></i><span class="more-app-item-text">代码片段</span></a><a class="more-app-list-item" href="https://mm.liushen.fun/" rel="nofollow noopener" target="_blank"><i class="more-app-item-icon fa-solid fa-pen-nib"></i><span class="more-app-item-text">提笔摘星</span></a><a class="more-app-list-item" href="https://pan.liushen.fun/" rel="nofollow noopener" target="_blank"><i class="more-app-item-icon fa-solid fa-cloud"></i><span class="more-app-item-text">清羽云盘</span></a><a class="more-app-list-item" href="https://um.liushen.fun/" rel="nofollow noopener" target="_blank"><i class="more-app-item-icon fa-solid fa-people-group"></i><span class="more-app-item-text">访客统计</span></a><a class="more-app-list-item" href="https://img.liiiu.cn/" rel="nofollow noopener" target="_blank"><i class="more-app-item-icon fa-solid fa-images"></i><span class="more-app-item-text">清羽图床</span></a><a class="more-app-list-item" href="https://chat.liushen.fun/" rel="nofollow noopener" target="_blank"><i class="more-app-item-icon fa-solid fa-robot"></i><span class="more-app-item-text">清羽AI</span></a><a class="more-app-list-item" href="https://bsz.liiiu.cn/" rel="nofollow noopener" target="_blank"><i class="more-app-item-icon fa-solid fa-chart-pie"></i><span class="more-app-item-text">不蒜计数</span></a><a class="more-app-list-item" href="https://status.liushen.fun/" rel="nofollow noopener" target="_blank"><i class="more-app-item-icon fa-solid fa-server"></i><span class="more-app-item-text">服务检测</span></a></div></div><div class="more-app-list-group"><div class="more-app-list-title">🚁实用工具</div><div class="more-app-list"><a class="more-app-list-item" href="https://tmail.qyliu.top/" rel="nofollow noopener" target="_blank"><i class="more-app-item-icon fa-solid fa-envelope"></i><span class="more-app-item-text">临时邮箱</span></a><a class="more-app-list-item" href="https://hot.liushen.fun/" rel="nofollow noopener" target="_blank"><i class="more-app-item-icon fa-solid fa-fire"></i><span class="more-app-item-text">每日热榜</span></a><a class="more-app-list-item" href="https://cover.qyliu.top/" rel="nofollow noopener" target="_blank"><i class="more-app-item-icon fa-solid fa-eye"></i><span class="more-app-item-text">封面设计</span></a><a class="more-app-list-item" href="https://mini-cover.qyliu.top/" rel="nofollow noopener" target="_blank"><i class="more-app-item-icon fa-solid fa-image"></i><span class="more-app-item-text">迷你封面</span></a><a class="more-app-list-item" href="https://icon.qyliu.top/" rel="nofollow noopener" target="_blank"><i class="more-app-item-icon fa-solid fa-icons"></i><span class="more-app-item-text">万能图标</span></a><a class="more-app-list-item" href="https://draw.qyliu.top/" rel="nofollow noopener" target="_blank"><i class="more-app-item-icon fa-solid fa-paintbrush"></i><span class="more-app-item-text">灵感白板</span></a><a class="more-app-list-item" href="https://mindmap.qyliu.top/" rel="nofollow noopener" target="_blank"><i class="more-app-item-icon fa-solid fa-network-wired"></i><span class="more-app-item-text">思维导图</span></a><a class="more-app-list-item" href="https://share.liushen.fun/#/" rel="nofollow noopener" target="_blank"><i class="more-app-item-icon fa-solid fa-share-nodes"></i><span class="more-app-item-text">内容中转</span></a></div></div></div></div></div><span id="blog-info"><a class="nav-site-title" href="/" title="LiuShen's Blog"><span class="site-name">LiuShen</span></a></span><div id="menus"></div><div class="menus_items visible"><div class="menus_item"><span class="site-page group hide"><i class="fa-fw fas fa-home"></i> <span>导航</span><i class="fas fa-chevron-down"></i></span><ul class="menus_item_child"><li><a class="site-page child" target="_blank" rel="noopener" href="https://www.liushen.fun/"><i class="fa-fw fa-solid fa-house-flag"></i> <span>个人主页</span></a></li><li><a class="site-page child" target="_blank" rel="noopener" href="https://xc.liushen.fun/"><i class="fa-fw fa fa-camera-retro"></i> <span>个人相册</span></a></li></ul></div><div class="menus_item"><span class="site-page group hide"><i class="fa-fw fa fa-graduation-cap"></i> <span>整理</span><i class="fas fa-chevron-down"></i></span><ul class="menus_item_child"><li><a class="site-page child" href="/archives/"><i class="fa-fw fas fa-archive"></i> <span>时光卷轴</span></a></li><li><a class="site-page child" href="/tags/"><i class="fa-fw fas fa-tags"></i> <span>文章标签</span></a></li><li><a class="site-page child" href="/categories/"><i class="fa-fw fas fa-folder-open"></i> <span>文章分类</span></a></li><li><a class="site-page child" href="/charts/"><i class="fa-fw fa-solid fa-chart-pie"></i> <span>文章通览</span></a></li></ul></div><div class="menus_item"><span class="site-page group hide"><i class="fa-fw fa-solid fa-user-group"></i> <span>友人</span><i class="fas fa-chevron-down"></i></span><ul class="menus_item_child"><li><a class="site-page child" href="/link/"><i class="fa-fw fas fa-link"></i> <span>友链展示</span></a></li><li><a class="site-page child" href="/addlink/"><i class="fa-fw fa fa-at"></i> <span>友链申请</span></a></li><li><a class="site-page child" href="/fcircle/"><i class="fa-fw fa-solid fa-circle-nodes"></i> <span>朋友动态</span></a></li></ul></div><div class="menus_item"><span class="site-page group hide"><i class="fa-fw fa fa-paper-plane"></i> <span>留言</span><i class="fas fa-chevron-down"></i></span><ul class="menus_item_child"><li><a class="site-page child" href="/comment/"><i class="fa-fw fa-solid fa-chalkboard"></i> <span>留言白板</span></a></li><li><a class="site-page child" target="_blank" rel="noopener" href="https://mm.liushen.fun/"><i class="fa-fw fa-solid fa-pen-nib"></i> <span>提笔摘星</span></a></li></ul></div><div class="menus_item"><span class="site-page group hide"><i class="fa-fw fa-solid fa-stethoscope"></i> <span>分享</span><i class="fas fa-chevron-down"></i></span><ul class="menus_item_child"><li><a class="site-page child" target="_blank" rel="noopener" href="https://gist.liushen.fun/"><i class="fa-fw fa-solid fa-code"></i> <span>代码片段</span></a></li><li><a class="site-page child" href="/subscribe/"><i class="fa-fw fa-solid fa-rss"></i> <span>订阅本站</span></a></li><li><a class="site-page child" target="_blank" rel="noopener" href="https://pan.liushen.fun/"><i class="fa-fw fa-solid fa-laptop-file"></i> <span>清羽云盘</span></a></li></ul></div><div class="menus_item"><span class="site-page group hide"><i class="fa-fw fa fa-list"></i> <span>关于</span><i class="fas fa-chevron-down"></i></span><ul class="menus_item_child"><li><a class="site-page child" href="/about/"><i class="fa-fw fa fa-address-card"></i> <span>站长资料</span></a></li><li><a class="site-page child" href="/shuoshuo/"><i class="fa-fw fa fa-commenting"></i> <span>日常说说</span></a></li><li><a class="site-page child" href="/devices/"><i class="fa-fw fa-solid fa-tachograph-digital"></i> <span>我的设备</span></a></li></ul></div></div><center id="name-container"><a id="page-name" href="javascript:btf.scrollToDest(0, 500)">PAGE_NAME</a></center><div id="nav-right"><div id="travellings"><a class="site-page" href="https://www.travellings.cn/go.html" title="友链接力-随机开往" target="_blank" rel="noopener nofollow"><i class="fa-solid fa-bus fa-fw"></i></a></div><div id="ten-years"><a class="site-page" href="https://foreverblog.cn/go.html" title="友链接力-十年之约" target="_blank" rel="noopener nofollow"><i class="fa-brands fa-nfc-symbol fa-fw"></i></a></div><div id="random"><a class="site-page" href="javascript:randomPost()" title="随机前往一个文章"><i class="fa-solid fa-shuffle fa-fw"></i></a></div><div id="search-button"><span class="site-page social-icon search"><i class="fas fa-search fa-fw"></i></span></div><div id="toggle-menu"><span class="site-page" href="javascript:void(0);" title="展开菜单"><i class="fas fa-indent fa-fw"></i></span></div></div></nav><div id="post-info"><h1 class="post-title">Github Action实现友链状态检测</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2024-06-23T17:00:00.000Z" title="发表于 2024-06-24 01:00:00">2024-06-24</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2024-09-20T01:00:00.000Z" title="更新于 2024-09-20 09:00:00">2024-09-20</time></span><span class="post-meta-categories"><span class="post-meta-separator">|</span><i class="fas fa-inbox fa-fw post-meta-icon"></i><a class="post-meta-categories" href="/categories/website/">博客管理</a></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-wordcount"><i class="far fa-file-word fa-fw post-meta-icon"></i><span class="post-meta-label">总字数:</span><span class="word-count">5.6k</span><span class="post-meta-separator">|</span><i class="far fa-clock fa-fw post-meta-icon"></i><span class="post-meta-label">阅读时长:</span><span>21分钟</span></span><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" data-flag-title=""><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">浏览量:</span><span id="busuanzi_page_pv"><i class="fa-solid fa-spinner fa-spin"></i></span></span><span class="post-meta-separator">|</span><span class="post-meta-commentcount"><i class="far fa-comments fa-fw post-meta-icon"></i><span class="post-meta-label">评论数:</span><a href="/posts/c2262998/#post-comment"><span id="ArtalkCount"><i class="fa-solid fa-spinner fa-spin"></i></span></a></span></div></div></div><section class="main-hero-waves-area waves-area"><svg class="waves-svg" xmlns="http://www.w3.org/2000/svg" xlink="http://www.w3.org/1999/xlink" viewBox="0 24 150 28" preserveAspectRatio="none" shape-rendering="auto"><defs><path id="gentle-wave" d="M-160 44c30 0 58-18 88-18s58 18 88 18 58-18 88-18 58 18 88 18v44h-352Z"></path></defs><g class="parallax"><use href="#gentle-wave" x="48" y="0"></use><use href="#gentle-wave" x="48" y="3"></use><use href="#gentle-wave" x="48" y="5"></use><use href="#gentle-wave" x="48" y="7"></use></g></svg></section></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><div class="ai-summary"><div class="ai-head"><div class="ai-head-left"><div class="ai-circle ai-circle-1"></div><div class="ai-circle ai-circle-2"></div><div class="ai-circle ai-circle-3"></div></div><div class="ai-head-right"><a class="ai-about-ai" href="/posts/40702a0d/">关于AI</a></div></div><div class="ai-explanation" style="display:block" data-summary="这里是清羽AI，这篇文章介绍了一种使用GitHub Action自动检测友链状态的方法。作者起初通过手动点击检验友链，但随着友链数量增至73条，这种方式变得低效。作者发现友链圈存在一个API，但判定机制滞后，于是编写了Python脚本在执行`hexo d`命令时同步检测友链状态，并将结果输出到控制台。后来，作者受到GitHub群友的启发，利用GitHub Action调度脚本运行，并生成HTML页面展示检测结果。作者进一步优化了方案，设计了美观的前端展示界面，并实现了类似API的功能输出所有友链数据的可达性。作者还针对适配性问题，使用了根目录下的txt文件进行检测，并最终通过JavaScript代码将实时检测结果嵌入到友情链接页面的每个卡片左上角，大大提升了友链管理的效率与直观性。文章还详细介绍了GitHub配置、获取方式、提升准确率和部署展示页面的步骤，为读者提供了完整的解决方案。">清羽AI正在绞尽脑汁想思路ING···</div><div class="ai-title"><div class="ai-title-left"><i class="fa-brands fa-slack"></i><div class="ai-title-text">清羽のAI摘要</div></div><div class="ai-tag" id="ai-tag">GLM-4-Flash</div></div></div><h2 id="碎碎念"><a href="#碎碎念" class="headerlink" title="碎碎念"></a>碎碎念</h2><p>起初，我管理友链时采取的是手动点击检验的方式，但随着时间的推移，友链数量逐渐增加至73条，这一做法显然已不再高效。我曾看到一些大佬实现了直接在友链卡片上标注可达状态的功能，遗憾的是，我并没有找到相关的教程。在探索过程中，我发现友链圈里存在一个API，它能够返回未能成功抓取的链接，原理是，如果某个站点在过去两个月内未曾产出新文章，则被视为不可达。然而，这种滞后性的判定机制明显影响了友链监测的即时性，所以生成的结果还是仅供参考。</p><p>于是，我动手编写了一个Python脚本，安排在执行<code>hexo d</code>命令时同步运行，以此来检测友链状态，并将检测结果输出到控制台，虽稍显原始，但也算是也勉强能用哈哈。偶然间在一次日常的糖果屋QQ群闲聊中，我看到了群友<a target="_blank" rel="external nofollow noopener noreferrer" href="/safego/?u=aHR0cHM6Ly9oZXhvLnNoYW5nc2tyLnRvcC8">安小歪</a>分享的一个方案，他利用<code>GitHub Actions</code>调度脚本运行，并最终生成比较简洁的HTML页面展示检测结果，这一思路启发了我。</p><p>在此基础上，我进一步优化了这一方案，设计出更为美观的前端展示界面，并额外写了一项类似<code>API</code>的功能，输出所有友链数据的可达性，针对适配性问题，我还使用根目录下的更加简洁的<code>txt</code>文件进行了适配检测并输出同样的内容。最终，借助编写好的<code>JavaScript</code>代码，我成功地将这些实时检测结果嵌入到了友情链接页面的每个卡片左上角，大大提升了友链管理的效率与直观性。</p><div class="liushen-tag-link"><a class="tag-Link" target="_blank" href="/safego/?u=aHR0cHM6Ly9naXRodWIuY29tL3dpbGxvdy1nb2QvY2hlY2stZmxpbms" rel="external nofollow noopener noreferrer"><div class="tag-link-tips">🙄引用站外地址，不保证站点的可用性和安全性</div><div class="tag-link-bottom"><div class="tag-link-left" style="background-image:url(https://p.liiiu.cn/i/2024/07/27/66a461a3098aa.webp)"></div><div class="tag-link-right"><div class="tag-link-title">check-flink，⚙️检查友链链接是否可达，可以大幅度减少检查工作量。</div><div class="tag-link-sitename">github.com@willow-god</div></div><i class="fa-solid fa-angle-right"></i></div></a></div><h2 id="功能概览"><a href="#功能概览" class="headerlink" title="功能概览"></a>功能概览</h2><ol><li><code>github action</code>自动定时检测友链状态，结果输出到page分支下的<code>result.json</code>。</li><li>友链状态展示页面，可以部署到<code>zeabur</code>或者<code>vercel</code>，加速<code>api</code>访问速度。</li><li>为确保兼容性，实现了两种检测方案：<ul><li>非兼容：使用<a href="https://blog.liushen.fun/flink_count.json">该格式文件</a>动态读取友链内容，实现功能，友链列表自动实时性更新。</li><li>兼容：使用<a target="_blank" rel="external nofollow noopener noreferrer" href="/safego/?u=aHR0cHM6Ly9naXRodWIuY29tL3dpbGxvdy1nb2QvY2hlY2stZmxpbmsvYmxvYi9tYWluL2xpbmsuY3N2">TXT</a>存储所有友链信息，兼容性好，适合所有站点，但是添加友链后可能需要手动更新文件。</li></ul></li><li><a target="_blank" rel="external nofollow noopener noreferrer" href="/safego/?u=aHR0cHM6Ly9jaGVjay56ZWFidXIuYXBwL3Jlc3VsdC5qc29u">API</a>访问数据，<code>api</code>包含数据包括可达链接，不可达链接，可达链接数目。不可达链接数目，更新时间戳，其中链接中包含站点名称和地址，便于前端部署。</li><li>测试脚本使用<code>python</code>，使用<code>Request</code>包的<code>get</code>和<code>head</code>两种检测方式检测，尽可能减少误判概率。</li><li>前端采用本地缓存，减少api调用次数，缓存半个小时刷新，不影响实时性。</li></ol><h2 id="使用教程"><a href="#使用教程" class="headerlink" title="使用教程"></a>使用教程</h2><h3 id="github配置"><a href="#github配置" class="headerlink" title="github配置"></a>github配置</h3><ol><li><p><strong>配置仓库权限</strong></p><p>在<code>GitHub</code>仓库的设置中，确保<code>Actions</code>有写权限，步骤如下：</p><ul><li><p>打开你的<code>GitHub</code>仓库，点击右上角的<code>Settings</code>。</p></li><li><p>在左侧栏中找到并点击<code>Actions</code>。</p></li><li><p>选择<code>General</code>。</p></li><li><p>在<code>Workflow permissions</code>部分，选择<code>Read and write permissions</code>。</p></li><li><p>点击<code>Save</code>按钮保存设置。</p></li></ul></li></ol><h3 id="获取方式"><a href="#获取方式" class="headerlink" title="获取方式"></a>获取方式</h3><h4 id="动态Json获取"><a href="#动态Json获取" class="headerlink" title="动态Json获取"></a>动态Json获取</h4><p>该方法适用于<code>hexo-theme-butterfly</code>，其他主题理论上也适配，但是需要自行修改代码实现相关功能，其实就是维护一个固定格式的友链在线列表。</p><p>首先，在<code>hexo</code>根目录下创建<code>link.js</code>，写入以下内容：</p><figure class="highlight javascript"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">const</span> <span class="variable constant_">YML</span> = <span class="built_in">require</span>(<span class="string">'yamljs'</span>)</span><br><span class="line"><span class="keyword">const</span> fs = <span class="built_in">require</span>(<span class="string">'fs'</span>)</span><br><span class="line"></span><br><span class="line"><span class="keyword">let</span> ls   = [],</span><br><span class="line">    data = <span class="variable constant_">YML</span>.<span class="title function_">parse</span>(fs.<span class="title function_">readFileSync</span>(<span class="string">'source/_data/link.yml'</span>).<span class="title function_">toString</span>().<span class="title function_">replace</span>(<span class="regexp">/(?&lt;=rss:)\s*\n/g</span>, <span class="string">' ""\n'</span>));</span><br><span class="line"></span><br><span class="line">data.<span class="title function_">forEach</span>(<span class="function">(<span class="params">e, i</span>) =&gt;</span> {</span><br><span class="line">    <span class="keyword">let</span> j = <span class="number">2</span>;  <span class="comment">//获取友链数组的范围（除了最后，前面的都获取）</span></span><br><span class="line">    <span class="keyword">if</span> (i &lt; j) ls = ls.<span class="title function_">concat</span>(e.<span class="property">link_list</span>)</span><br><span class="line">});</span><br><span class="line">fs.<span class="title function_">writeFileSync</span>(<span class="string">'./source/flink_count.json'</span>, <span class="string">`{"link_list": <span class="subst">${<span class="built_in">JSON</span>.stringify(ls)}</span>,"length":<span class="subst">${ls.length}</span>}`</span>)</span><br><span class="line"><span class="variable language_">console</span>.<span class="title function_">log</span>(<span class="string">'flink_count.json 文件已生成。'</span>);</span><br></pre></td></tr></tbody></table></figure><p>其中的<code>j</code>表示获取的友链数组的范围，比如你只想要第一组，那么填写<code>1</code>即可。</p><p>根目录下执行以下内容：</p><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">node link.js</span><br></pre></td></tr></tbody></table></figure><p>你将在<code>[HexoRoot]/source</code>文件夹下看到<code>flink_count.json</code>文件，文件格式如下：</p><figure class="highlight json"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br></pre></td><td class="code"><pre><span class="line"><span class="punctuation">{</span></span><br><span class="line">  <span class="attr">"link_list"</span><span class="punctuation">:</span> <span class="punctuation">[</span></span><br><span class="line">    <span class="punctuation">{</span></span><br><span class="line">      <span class="attr">"name"</span><span class="punctuation">:</span> <span class="string">"String"</span><span class="punctuation">,</span></span><br><span class="line">      <span class="attr">"link"</span><span class="punctuation">:</span> <span class="string">"String"</span><span class="punctuation">,</span></span><br><span class="line">      <span class="attr">"avatar"</span><span class="punctuation">:</span> <span class="string">"String"</span><span class="punctuation">,</span></span><br><span class="line">      <span class="attr">"descr"</span><span class="punctuation">:</span> <span class="string">"String"</span><span class="punctuation">,</span></span><br><span class="line">      <span class="attr">"siteshot"</span><span class="punctuation">:</span> <span class="string">"String"</span></span><br><span class="line">    <span class="punctuation">}</span><span class="punctuation">,</span><span class="punctuation">{</span></span><br><span class="line">      <span class="attr">"name"</span><span class="punctuation">:</span> <span class="string">"String"</span><span class="punctuation">,</span></span><br><span class="line">      <span class="attr">"link"</span><span class="punctuation">:</span> <span class="string">"String"</span><span class="punctuation">,</span></span><br><span class="line">      <span class="attr">"avatar"</span><span class="punctuation">:</span> <span class="string">"String"</span><span class="punctuation">,</span></span><br><span class="line">      <span class="attr">"descr"</span><span class="punctuation">:</span> <span class="string">"String"</span><span class="punctuation">,</span></span><br><span class="line">      <span class="attr">"siteshot"</span><span class="punctuation">:</span> <span class="string">"String"</span></span><br><span class="line">    <span class="punctuation">}</span><span class="punctuation">,</span></span><br><span class="line">    <span class="comment">// ... 其他76个博客站点信息</span></span><br><span class="line">  <span class="punctuation">]</span><span class="punctuation">,</span></span><br><span class="line">  <span class="attr">"length"</span><span class="punctuation">:</span> <span class="number">77</span></span><br><span class="line"><span class="punctuation">}</span></span><br></pre></td></tr></tbody></table></figure><p>该文件将在执行<code>hexo g</code>命令时进入<code>[BlogRoot]/public</code>目录下，并上传到网络上。</p><p>为了方便，可以写一个脚本，代替执行<code>hexo d</code>的功能（可选）：</p><figure class="highlight bash"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line">@<span class="built_in">echo</span> off</span><br><span class="line">E:</span><br><span class="line"><span class="built_in">cd</span> E:\Programming\HTML_Language\willow-God\blog</span><br><span class="line">node link.js &amp;&amp; hexo g &amp;&amp; hexo algolia &amp;&amp; hexo d</span><br></pre></td></tr></tbody></table></figure><p>如果你使用 <code>github action</code> 构建站点，则更方便，在 <code>hexo g</code> 前面任意位置添加：</p><figure class="highlight yaml"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="string">npm</span> <span class="string">install</span> <span class="string">yamljs</span> <span class="string">--save</span></span><br><span class="line"><span class="string">node</span> <span class="string">link.js</span></span><br></pre></td></tr></tbody></table></figure><p>上传之后，你就可以使用路径：<code>https://blog.example.com/flink_count.json</code>获取到所有的友链数据，下面修改<code>github</code>上的文件：<code>test-friend.py</code></p><figure class="highlight python"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> json</span><br><span class="line"><span class="keyword">import</span> requests</span><br><span class="line"><span class="keyword">import</span> warnings</span><br><span class="line"><span class="keyword">import</span> time</span><br><span class="line"><span class="keyword">import</span> concurrent.futures</span><br><span class="line"><span class="keyword">from</span> datetime <span class="keyword">import</span> datetime</span><br><span class="line"><span class="keyword">from</span> queue <span class="keyword">import</span> Queue</span><br><span class="line"><span class="keyword">import</span> os</span><br><span class="line"></span><br><span class="line"><span class="comment"># 忽略警告信息</span></span><br><span class="line">warnings.filterwarnings(<span class="string">"ignore"</span>, message=<span class="string">"Unverified HTTPS request is being made.*"</span>)</span><br><span class="line"></span><br><span class="line"><span class="comment"># 用户代理字符串，模仿浏览器</span></span><br><span class="line">user_agent = <span class="string">"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36"</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># API Key 和 请求URL的模板</span></span><br><span class="line"><span class="comment"># 判断是否在本地运行，如果是则从环境变量中获取API Key</span></span><br><span class="line"><span class="keyword">if</span> os.getenv(<span class="string">"LIJIANGAPI_TOKEN"</span>) <span class="keyword">is</span> <span class="literal">None</span>:</span><br><span class="line">    <span class="built_in">print</span>(<span class="string">"本地运行，从环境变量中加载并获取API Key"</span>)</span><br><span class="line">    <span class="keyword">from</span> dotenv <span class="keyword">import</span> load_dotenv</span><br><span class="line">    load_dotenv()</span><br><span class="line"><span class="keyword">else</span>:</span><br><span class="line">    <span class="built_in">print</span>(<span class="string">"在服务器上运行，从环境变量中获取API Key"</span>)</span><br><span class="line"></span><br><span class="line">api_key = os.getenv(<span class="string">"LIJIANGAPI_TOKEN"</span>)</span><br><span class="line">api_url_template = <span class="string">"https://api.nsmao.net/api/web/query?key={}&amp;url={}"</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># 代理链接的模板，代理是通过在代理地址后加目标 URL 来请求，代理地址确保以 / 结尾</span></span><br><span class="line">proxy_url = os.getenv(<span class="string">"PROXY_URL"</span>)</span><br><span class="line"><span class="keyword">if</span> proxy_url <span class="keyword">is</span> <span class="keyword">not</span> <span class="literal">None</span>:</span><br><span class="line">    proxy_url_template = proxy_url + <span class="string">"{}"</span></span><br><span class="line"><span class="keyword">else</span>:</span><br><span class="line">    proxy_url_template = <span class="literal">None</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># 初始化一个队列来处理API请求</span></span><br><span class="line">api_request_queue = Queue()</span><br><span class="line"></span><br><span class="line"><span class="comment"># API 请求处理函数，确保每秒不超过5次请求</span></span><br><span class="line"><span class="keyword">def</span> <span class="title function_">handle_api_requests</span>():</span><br><span class="line">    <span class="keyword">while</span> <span class="keyword">not</span> api_request_queue.empty():</span><br><span class="line">        item = api_request_queue.get()</span><br><span class="line">        headers = {<span class="string">"User-Agent"</span>: user_agent}</span><br><span class="line">        link = item[<span class="string">'link'</span>]</span><br><span class="line">        <span class="keyword">if</span> api_key <span class="keyword">is</span> <span class="literal">None</span>:</span><br><span class="line">            <span class="built_in">print</span>(<span class="string">"API Key 未提供，无法通过API访问"</span>)</span><br><span class="line">            item[<span class="string">'latency'</span>] = -<span class="number">1</span></span><br><span class="line">            <span class="keyword">break</span></span><br><span class="line">        api_url = api_url_template.<span class="built_in">format</span>(api_key, link)</span><br><span class="line"></span><br><span class="line">        <span class="keyword">try</span>:</span><br><span class="line">            response = requests.get(api_url, headers=headers, timeout=<span class="number">15</span>, verify=<span class="literal">True</span>)</span><br><span class="line">            response_data = response.json()</span><br><span class="line"></span><br><span class="line">            <span class="comment"># 提取API返回的code和exec_time</span></span><br><span class="line">            <span class="keyword">if</span> response_data[<span class="string">'code'</span>] == <span class="number">200</span>:</span><br><span class="line">                latency = <span class="built_in">round</span>(response_data[<span class="string">'exec_time'</span>], <span class="number">2</span>)</span><br><span class="line">                <span class="built_in">print</span>(<span class="string">f"成功通过API访问 <span class="subst">{link}</span>, 延迟为 <span class="subst">{latency}</span> 秒"</span>)</span><br><span class="line">                item[<span class="string">'latency'</span>] = latency</span><br><span class="line">            <span class="keyword">else</span>:</span><br><span class="line">                <span class="built_in">print</span>(<span class="string">f"API返回错误，code: <span class="subst">{response_data[<span class="string">'code'</span>]}</span>，无法访问 <span class="subst">{link}</span>"</span>)</span><br><span class="line">                item[<span class="string">'latency'</span>] = -<span class="number">1</span></span><br><span class="line">        <span class="keyword">except</span> requests.RequestException:</span><br><span class="line">            <span class="built_in">print</span>(<span class="string">f"API请求失败，无法访问 <span class="subst">{link}</span>"</span>)</span><br><span class="line">            item[<span class="string">'latency'</span>] = -<span class="number">1</span></span><br><span class="line"></span><br><span class="line">        time.sleep(<span class="number">0.2</span>)  <span class="comment"># 控制API请求速率，确保每秒不超过5次</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># 检查链接是否可访问的函数并测量时延</span></span><br><span class="line"><span class="keyword">def</span> <span class="title function_">check_link_accessibility</span>(<span class="params">item</span>):</span><br><span class="line">    headers = {<span class="string">"User-Agent"</span>: user_agent}</span><br><span class="line">    link = item[<span class="string">'link'</span>]</span><br><span class="line">    latency = -<span class="number">1</span></span><br><span class="line"></span><br><span class="line">    <span class="comment"># 1. 首先尝试直接访问</span></span><br><span class="line">    <span class="keyword">try</span>:</span><br><span class="line">        start_time = time.time()</span><br><span class="line">        response = requests.get(link, headers=headers, timeout=<span class="number">15</span>, verify=<span class="literal">True</span>)</span><br><span class="line">        latency = <span class="built_in">round</span>(time.time() - start_time, <span class="number">2</span>)</span><br><span class="line">        <span class="keyword">if</span> response.status_code == <span class="number">200</span>:</span><br><span class="line">            <span class="built_in">print</span>(<span class="string">f"成功通过直接访问 <span class="subst">{link}</span>, 延迟为 <span class="subst">{latency}</span> 秒"</span>)</span><br><span class="line">            <span class="keyword">return</span> [item, latency]</span><br><span class="line">    <span class="keyword">except</span> requests.RequestException:</span><br><span class="line">        <span class="built_in">print</span>(<span class="string">f"直接访问失败 <span class="subst">{link}</span>"</span>)</span><br><span class="line"></span><br><span class="line">    <span class="comment"># 2. 尝试通过代理访问(可选)</span></span><br><span class="line">    <span class="keyword">if</span> proxy_url_template <span class="keyword">is</span> <span class="literal">None</span>:</span><br><span class="line">        <span class="built_in">print</span>(<span class="string">"未提供代理地址，无法通过代理访问"</span>)</span><br><span class="line">    <span class="keyword">else</span>:</span><br><span class="line">        proxy_url = proxy_url_template.<span class="built_in">format</span>(link)</span><br><span class="line">        <span class="keyword">try</span>:</span><br><span class="line">            start_time = time.time()</span><br><span class="line">            response = requests.get(proxy_url, headers=headers, timeout=<span class="number">15</span>, verify=<span class="literal">True</span>)</span><br><span class="line">            latency = <span class="built_in">round</span>(time.time() - start_time, <span class="number">2</span>)</span><br><span class="line">            <span class="keyword">if</span> response.status_code == <span class="number">200</span>:</span><br><span class="line">                <span class="built_in">print</span>(<span class="string">f"成功通过代理访问 <span class="subst">{link}</span>, 延迟为 <span class="subst">{latency}</span> 秒"</span>)</span><br><span class="line">                <span class="keyword">return</span> [item, latency]</span><br><span class="line">        <span class="keyword">except</span> requests.RequestException:</span><br><span class="line">            <span class="built_in">print</span>(<span class="string">f"代理访问失败 <span class="subst">{link}</span>"</span>)</span><br><span class="line"></span><br><span class="line">    <span class="comment"># 3. 如果代理也失败，添加到API队列中</span></span><br><span class="line">    item[<span class="string">'latency'</span>] = -<span class="number">1</span></span><br><span class="line">    api_request_queue.put(item)</span><br><span class="line">    <span class="keyword">return</span> [item, latency]</span><br><span class="line"></span><br><span class="line"><span class="comment"># 目标JSON数据的URL</span></span><br><span class="line">json_url = <span class="string">'https://blog.liushen.fun/flink_count.json'</span>   <span class="comment"># 改的是这里！！！</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># 发送HTTP GET请求获取JSON数据</span></span><br><span class="line">response = requests.get(json_url)</span><br><span class="line"><span class="keyword">if</span> response.status_code == <span class="number">200</span>:</span><br><span class="line">    data = response.json()  <span class="comment"># 解析JSON数据</span></span><br><span class="line">    link_list = data[<span class="string">'link_list'</span>]  <span class="comment"># 提取所有的链接项</span></span><br><span class="line"><span class="keyword">else</span>:</span><br><span class="line">    <span class="built_in">print</span>(<span class="string">f"Failed to retrieve data, status code: <span class="subst">{response.status_code}</span>"</span>)</span><br><span class="line">    exit()</span><br><span class="line"></span><br><span class="line"><span class="comment"># 使用ThreadPoolExecutor并发检查多个链接</span></span><br><span class="line"><span class="keyword">with</span> concurrent.futures.ThreadPoolExecutor(max_workers=<span class="number">10</span>) <span class="keyword">as</span> executor:</span><br><span class="line">    results = <span class="built_in">list</span>(executor.<span class="built_in">map</span>(check_link_accessibility, link_list))</span><br><span class="line"></span><br><span class="line"><span class="comment"># 处理API请求</span></span><br><span class="line">handle_api_requests()</span><br><span class="line"></span><br><span class="line"><span class="comment"># 添加时延信息到每个链接项</span></span><br><span class="line">link_status = [{<span class="string">'name'</span>: result[<span class="number">0</span>][<span class="string">'name'</span>], <span class="string">'link'</span>: result[<span class="number">0</span>][<span class="string">'link'</span>], <span class="string">'latency'</span>: result[<span class="number">0</span>].get(<span class="string">'latency'</span>, result[<span class="number">1</span>])} <span class="keyword">for</span> result <span class="keyword">in</span> results]</span><br><span class="line"></span><br><span class="line"><span class="comment"># 获取当前时间</span></span><br><span class="line">current_time = datetime.now().strftime(<span class="string">"%Y-%m-%d %H:%M:%S"</span>)</span><br><span class="line"></span><br><span class="line"><span class="comment"># 统计可访问和不可访问的链接数，计算 accessible_count 和 inaccessible_count</span></span><br><span class="line">accessible_count = <span class="number">0</span></span><br><span class="line">inaccessible_count = <span class="number">0</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">for</span> result <span class="keyword">in</span> results:</span><br><span class="line">    <span class="comment"># print(result[1])</span></span><br><span class="line">    <span class="keyword">if</span> result[<span class="number">1</span>] != -<span class="number">1</span>:</span><br><span class="line">        accessible_count += <span class="number">1</span></span><br><span class="line">    <span class="keyword">else</span>:</span><br><span class="line">        inaccessible_count += <span class="number">1</span></span><br><span class="line"></span><br><span class="line"><span class="comment"># 计算 total_count</span></span><br><span class="line">total_count = <span class="built_in">len</span>(results)</span><br><span class="line"></span><br><span class="line"><span class="comment"># 将结果写入JSON文件</span></span><br><span class="line">output_json_path = <span class="string">'./result.json'</span></span><br><span class="line"><span class="keyword">with</span> <span class="built_in">open</span>(output_json_path, <span class="string">'w'</span>, encoding=<span class="string">'utf-8'</span>) <span class="keyword">as</span> file:</span><br><span class="line">    json.dump({</span><br><span class="line">        <span class="string">'timestamp'</span>: current_time,</span><br><span class="line">        <span class="string">'accessible_count'</span>: accessible_count,</span><br><span class="line">        <span class="string">'inaccessible_count'</span>: inaccessible_count,</span><br><span class="line">        <span class="string">'total_count'</span>: total_count,</span><br><span class="line">        <span class="string">'link_status'</span>: link_status</span><br><span class="line">    }, file, ensure_ascii=<span class="literal">False</span>, indent=<span class="number">4</span>)</span><br><span class="line"></span><br><span class="line"><span class="built_in">print</span>(<span class="string">f"检查完成，结果已保存至 '<span class="subst">{output_json_path}</span>' 文件。"</span>)</span><br></pre></td></tr></tbody></table></figure><p>修改其中的<code>json_url</code>为你的对应地址，保存即可。由于<code>github action</code>脚本默认方式即为这种方式，所以不需要进行修改。</p><h4 id="静态csv获取"><a href="#静态csv获取" class="headerlink" title="静态csv获取"></a>静态csv获取</h4><p>这个方式较为简单，但是维护稍微有点点麻烦，你需要将所有数据写到仓库根目录的<code>link.csv</code>文件中，格式如下：</p><figure class="highlight txt"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">清羽飞扬,https://blog.liushen.fun/</span><br><span class="line">ChrisKim,https://www.zouht.com/</span><br><span class="line">Akilar,https://akilar.top/</span><br><span class="line">张洪Heo,https://blog.zhheo.com/</span><br><span class="line">安知鱼,https://blog.anheyu.com/</span><br><span class="line">杜老师说,https://dusays.com</span><br><span class="line">Tianli,https://tianli-blog.club/</span><br><span class="line">贰猹,https://noionion.top/</span><br></pre></td></tr></tbody></table></figure><p>其中前面是名称，后面是链接，名称是为了使我们的结果<code>json</code>数据更加全面，同时和上面<code>动态Json获取</code>的方式统一，减少后面部分的工作量，增强兼容性。</p><p>处理这部分可能比较消耗时间。</p><div class="liushen-tag-link"><a class="tag-Link" target="_blank" href="/safego/?u=aHR0cHM6Ly9raW1pLm1vb25zaG90LmNuLw" rel="external nofollow noopener noreferrer"><div class="tag-link-tips">🙄引用站外地址，不保证站点的可用性和安全性</div><div class="tag-link-bottom"><div class="tag-link-left" style="background-image:url(https://p.liiiu.cn/i/2024/07/27/66a4632bbf06e.webp)"></div><div class="tag-link-right"><div class="tag-link-title">KIMI智能助手，欢迎探索月之暗面</div><div class="tag-link-sitename">月之暗面||moonshot.cn</div></div><i class="fa-solid fa-angle-right"></i></div></a></div><p>这里可以使用<code>kimi</code>帮你整理，自行组织语言并命令，复制最终结果并保存即可。</p><p><img src="" data-lazy-src="https://p.liiiu.cn/i/2024/06/23/6678337c78ff4.webp" alt="我的整理方式"></p><p>下面修改<code>github action</code>脚本内容，修改其中运行python脚本的部分：</p><figure class="highlight yaml"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="bullet">-</span> <span class="attr">name:</span> <span class="string">Run</span> <span class="string">Python</span> <span class="string">script</span> <span class="string">to</span> <span class="string">check</span> <span class="string">frined-links</span></span><br><span class="line">  <span class="attr">env:</span></span><br><span class="line">     <span class="attr">LIJIANGAPI_TOKEN:</span> <span class="string">${{</span> <span class="string">secrets.LIJIANGAPI_TOKEN</span> <span class="string">}}</span></span><br><span class="line">     <span class="attr">PROXY_URL:</span> <span class="string">${{</span> <span class="string">secrets.PROXY_URL</span> <span class="string">}}</span></span><br><span class="line">  <span class="attr">run:</span> <span class="string">python</span> <span class="string">test-friend-in-txt.py</span></span><br></pre></td></tr></tbody></table></figure><p>修改结束，最终结果是一样的，所以并不影响任何后续操作，如果action正确运行，则你的结果应该出现在另一个分支了。（page）分支。</p><h3 id="提升准确率"><a href="#提升准确率" class="headerlink" title="提升准确率"></a>提升准确率</h3><p>由于该脚本通过action进行，可能会出现由于各种原因导致准确率极低的现象发生，此时我们需要通过各种方式提升检测的准确率，本脚本内置了通过<a target="_blank" rel="external nofollow noopener noreferrer" href="/safego/?u=aHR0cHM6Ly9hcGkubnNtYW8ubmV0Lw">梨酱API</a>和<a target="_blank" rel="external nofollow noopener noreferrer" href="/safego/?u=aHR0cHM6Ly93d3cuY2xvdWRmbGFyZS5jb20vemgtY24v">CloudFlare Worker</a>转发的方式，可以分别应对屏蔽国外，以及使用国外CDN且防火墙屏蔽Github的两种情况，经过实测，最终准确率基本达到100%。</p><p>启用两种方式非常简单，仅需要设置对应的环境变量即可。</p><ol><li><p><strong>梨酱API</strong>:</p><p>打开<a target="_blank" rel="external nofollow noopener noreferrer" href="/safego/?u=aHR0cHM6Ly9hcGkubnNtYW8ubmV0Lw">梨酱API</a>并在右上角注册完成，进入控制台。进入控制台后，点击左边的密钥管理，生成密钥。</p><p><img src="" data-lazy-src="https://p.liiiu.cn/i/2024/09/20/66ecd375c8640.webp" alt="梨酱api"></p><p>然后再在仓库设置-&gt;secret-&gt;action中，添加<code>LIJIANGAPI_TOKEN</code>的密钥即可自动启用。</p></li><li><p><strong>CloudFlare Worker</strong>：</p><p>其实上面的梨酱api就可以达到很高的准确率了，如果仍然有部分站本身能访问却无法检测，你可以尝试使用下面的方式进行检测：</p><p>首先部署转发代理，具体教程可以点击<a href="https://blog.liushen.fun/posts/dd89adc9/">查看文章</a>，不需要绑定域名，因为github action本身就是国外环境。</p><p>然后添加密钥<code>PROXY_URL</code>，设置密钥即自动启用。</p></li></ol><h3 id="部署展示页面"><a href="#部署展示页面" class="headerlink" title="部署展示页面"></a>部署展示页面</h3><p>在成功运行一次后，该仓库即成为了一个前端页面，可以自行安排上传到哪里，这里选择zeabur上传，以下是大致步骤：</p><ol><li><strong>登录Vercel或Zeabur</strong>：<ul><li>如果还没有账户，请先注册一个 <code>Vercel</code> 或 <code>Zeabur</code> 账户。</li><li>登录后进入仪表板。</li></ul></li><li><strong>导入GitHub仓库</strong>：<ul><li>点击<code>New Project</code>或<code>Import Project</code>按钮。</li><li>选择<code>Import Git Repository</code>。</li><li>连接到您的 <code>GitHub</code>账户，并选择该链接检查项目的仓库。</li></ul></li><li><strong>配置项目</strong>：<ul><li>确保选择正确的分支（<code>page</code>）。</li><li>对于 <code>Vercel</code>，在 <code>Build and Output Settings</code>中，确保 <code>output.json</code> 文件在构建输出目录中。</li></ul></li><li><strong>部署项目</strong>：<ul><li>点击Deploy按钮开始部署。</li><li>部署完成后，<code>Vercel</code> 或 <code>Zeabur</code> 会生成一个 URL，您可以使用这个 URL 访问部署的网页。</li></ul></li></ol><p>此时如果不出意外，前端页面应该可以展示数据了，如下：</p><p><img src="" data-lazy-src="https://p.liiiu.cn/i/2024/09/20/66ecd3d2daf44.webp" alt="展示数据"></p><p>使用zeabur或者vercel部署的目的是加快结果文件国内访问并且展示最终结果， Vercel 或 Zeabur 平台可以跟随仓库更新实时同步内容，配合上前端的缓存和异步加载，哪怕是国内访问也可以得到非常好的体验，可以在我的友链页面测试。</p><h3 id="将数据展示到前端"><a href="#将数据展示到前端" class="headerlink" title="将数据展示到前端"></a>将数据展示到前端</h3><h4 id="通用解释"><a href="#通用解释" class="headerlink" title="通用解释"></a>通用解释</h4><p>通过上面部署，我们就可以通过地址访问获得的数据了（用本站部署的作为示例）：</p><figure class="highlight txt"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">https://check.zeabur.app/result.json</span><br></pre></td></tr></tbody></table></figure><p>链接检查结果以<code>JSON</code>格式存储，主要包含以下字段：</p><ul><li><code>accessible_links</code>: 可访问的链接列表。</li><li><code>inaccessible_links</code>: 不可访问的链接列表。</li><li><code>timestamp</code>: 生成检查结果的时间戳。</li></ul><p>以下是一个示例结构：</p><figure class="highlight json"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br></pre></td><td class="code"><pre><span class="line"><span class="punctuation">{</span></span><br><span class="line">    <span class="attr">"timestamp"</span><span class="punctuation">:</span> <span class="string">"2024-09-19 09:18:49"</span><span class="punctuation">,</span></span><br><span class="line">    <span class="attr">"accessible_count"</span><span class="punctuation">:</span> <span class="number">64</span><span class="punctuation">,</span></span><br><span class="line">    <span class="attr">"inaccessible_count"</span><span class="punctuation">:</span> <span class="number">12</span><span class="punctuation">,</span></span><br><span class="line">    <span class="attr">"total_count"</span><span class="punctuation">:</span> <span class="number">76</span><span class="punctuation">,</span></span><br><span class="line">    <span class="attr">"link_status"</span><span class="punctuation">:</span> <span class="punctuation">[</span></span><br><span class="line">        <span class="punctuation">{</span></span><br><span class="line">            <span class="attr">"name"</span><span class="punctuation">:</span> <span class="string">"清羽飞扬"</span><span class="punctuation">,</span></span><br><span class="line">            <span class="attr">"link"</span><span class="punctuation">:</span> <span class="string">"https://blog.qyliu.top/"</span><span class="punctuation">,</span></span><br><span class="line">            <span class="attr">"latency"</span><span class="punctuation">:</span> <span class="number">-1</span><span class="punctuation">,</span></span><br><span class="line">        <span class="punctuation">}</span><span class="punctuation">,</span></span><br><span class="line">        <span class="punctuation">{</span></span><br><span class="line">            <span class="attr">"name"</span><span class="punctuation">:</span> <span class="string">"ChrisKim"</span><span class="punctuation">,</span></span><br><span class="line">            <span class="attr">"link"</span><span class="punctuation">:</span> <span class="string">"https://www.zouht.com/"</span><span class="punctuation">,</span></span><br><span class="line">            <span class="attr">"latency"</span><span class="punctuation">:</span> <span class="number">0.76</span><span class="punctuation">,</span></span><br><span class="line">        <span class="punctuation">}</span><span class="punctuation">,</span></span><br><span class="line">        <span class="punctuation">{</span></span><br><span class="line">            <span class="attr">"name"</span><span class="punctuation">:</span> <span class="string">"Akilar"</span><span class="punctuation">,</span></span><br><span class="line">            <span class="attr">"link"</span><span class="punctuation">:</span> <span class="string">"https://akilar.top/"</span><span class="punctuation">,</span></span><br><span class="line">            <span class="attr">"latency"</span><span class="punctuation">:</span> <span class="number">3.31</span><span class="punctuation">,</span></span><br><span class="line">        <span class="punctuation">}</span><span class="punctuation">,</span></span><br><span class="line">    <span class="punctuation">]</span></span><br><span class="line"><span class="punctuation">}</span></span><br></pre></td></tr></tbody></table></figure><p>比如，你可以通过以下页面展示其友链数据到前端，当然，该代码仅作解释，具体效果请自行实现：</p><figure class="highlight javascript"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br></pre></td><td class="code"><pre><span class="line"><span class="title function_">fetch</span>(<span class="string">'./result.json'</span>)</span><br><span class="line">    .<span class="title function_">then</span>(<span class="function"><span class="params">response</span> =&gt;</span> response.<span class="title function_">json</span>())</span><br><span class="line">    .<span class="title function_">then</span>(<span class="function"><span class="params">data</span> =&gt;</span> {</span><br><span class="line">        <span class="comment">// 提取整体统计信息</span></span><br><span class="line">        <span class="keyword">const</span> summary = <span class="string">`总数: <span class="subst">${data.total_count}</span> | 可访问: <span class="subst">${data.accessible_count}</span> | 不可访问: <span class="subst">${data.inaccessible_count}</span>`</span>;</span><br><span class="line">        <span class="variable language_">document</span>.<span class="title function_">getElementById</span>(<span class="string">'summary'</span>).<span class="property">textContent</span> = summary + <span class="string">` | 检测时间: <span class="subst">${data.timestamp}</span>`</span>;</span><br><span class="line"></span><br><span class="line">        <span class="comment">// 动态生成表格数据</span></span><br><span class="line">        <span class="keyword">const</span> tbody = <span class="variable language_">document</span>.<span class="title function_">getElementById</span>(<span class="string">'link-table-body'</span>);</span><br><span class="line">        data.<span class="property">link_status</span>.<span class="title function_">forEach</span>(<span class="function"><span class="params">item</span> =&gt;</span> {</span><br><span class="line">            <span class="keyword">const</span> row = <span class="variable language_">document</span>.<span class="title function_">createElement</span>(<span class="string">'tr'</span>);</span><br><span class="line"></span><br><span class="line">            <span class="comment">// 名称列</span></span><br><span class="line">            <span class="keyword">const</span> nameCell = <span class="variable language_">document</span>.<span class="title function_">createElement</span>(<span class="string">'td'</span>);</span><br><span class="line">            nameCell.<span class="property">textContent</span> = item.<span class="property">name</span>;</span><br><span class="line">            row.<span class="title function_">appendChild</span>(nameCell);</span><br><span class="line"></span><br><span class="line">            <span class="comment">// 链接列</span></span><br><span class="line">            <span class="keyword">const</span> linkCell = <span class="variable language_">document</span>.<span class="title function_">createElement</span>(<span class="string">'td'</span>);</span><br><span class="line">            <span class="keyword">const</span> linkElement = <span class="variable language_">document</span>.<span class="title function_">createElement</span>(<span class="string">'a'</span>);</span><br><span class="line">            linkElement.<span class="property">href</span> = item.<span class="property">link</span>;</span><br><span class="line">            linkElement.<span class="property">target</span> = <span class="string">"_blank"</span>;</span><br><span class="line">            linkElement.<span class="property">textContent</span> = item.<span class="property">link</span>;</span><br><span class="line">            linkCell.<span class="title function_">appendChild</span>(linkElement);</span><br><span class="line">            row.<span class="title function_">appendChild</span>(linkCell);</span><br><span class="line"></span><br><span class="line">            <span class="comment">// 时延列</span></span><br><span class="line">            <span class="keyword">const</span> latencyCell = <span class="variable language_">document</span>.<span class="title function_">createElement</span>(<span class="string">'td'</span>);</span><br><span class="line">            latencyCell.<span class="property">textContent</span> = item.<span class="property">latency</span> &gt;= <span class="number">0</span> ? item.<span class="property">latency</span>.<span class="title function_">toFixed</span>(<span class="number">2</span>) : <span class="string">'不可达'</span>;</span><br><span class="line">            row.<span class="title function_">appendChild</span>(latencyCell);</span><br><span class="line"></span><br><span class="line">            <span class="comment">// SSL 状态列</span></span><br><span class="line">            <span class="keyword">const</span> sslCell = <span class="variable language_">document</span>.<span class="title function_">createElement</span>(<span class="string">'td'</span>);</span><br><span class="line">            sslCell.<span class="property">textContent</span> = item.<span class="property">ssl_status</span> ? <span class="string">'✔️'</span> : <span class="string">'❌'</span>;</span><br><span class="line">            row.<span class="title function_">appendChild</span>(sslCell);</span><br><span class="line"></span><br><span class="line">            tbody.<span class="title function_">appendChild</span>(row);</span><br><span class="line">        });</span><br><span class="line">    })</span><br><span class="line">    .<span class="title function_">catch</span>(<span class="function"><span class="params">error</span> =&gt;</span> {</span><br><span class="line">        <span class="variable language_">console</span>.<span class="title function_">error</span>(<span class="string">'Error loading JSON data:'</span>, error);</span><br><span class="line">        <span class="keyword">const</span> tbody = <span class="variable language_">document</span>.<span class="title function_">getElementById</span>(<span class="string">'link-table-body'</span>);</span><br><span class="line">        <span class="keyword">const</span> row = <span class="variable language_">document</span>.<span class="title function_">createElement</span>(<span class="string">'tr'</span>);</span><br><span class="line">        <span class="keyword">const</span> cell = <span class="variable language_">document</span>.<span class="title function_">createElement</span>(<span class="string">'td'</span>);</span><br><span class="line">        cell.<span class="property">colSpan</span> = <span class="number">4</span>;</span><br><span class="line">        cell.<span class="property">textContent</span> = <span class="string">'无法加载数据'</span>;</span><br><span class="line">        cell.<span class="property">style</span>.<span class="property">textAlign</span> = <span class="string">'center'</span>;</span><br><span class="line">        row.<span class="title function_">appendChild</span>(cell);</span><br><span class="line">        tbody.<span class="title function_">appendChild</span>(row);</span><br><span class="line">    });</span><br></pre></td></tr></tbody></table></figure><h4 id="本站方案"><a href="#本站方案" class="headerlink" title="本站方案"></a>本站方案</h4><p><strong>注意，本站采用方案需要按照本站教程魔改友情链接页面，否则需要自行修改代码内容，所以仅供参考，请以自身情况为准</strong></p><p>在<code>[BlogRoot]/source/link/index.md</code>下方填写以下内容：</p><figure class="highlight html"><table><tbody><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br></pre></td><td class="code"><pre><span class="line"><span class="tag">&lt;<span class="name">style</span>&gt;</span><span class="language-css"></span></span><br><span class="line"><span class="language-css">    <span class="selector-class">.status-tag</span> {</span></span><br><span class="line"><span class="language-css">        <span class="attribute">position</span>: absolute;</span></span><br><span class="line"><span class="language-css">        <span class="attribute">top</span>: <span class="number">0px</span>;</span></span><br><span class="line"><span class="language-css">        <span class="attribute">left</span>: <span class="number">0px</span>;</span></span><br><span class="line"><span class="language-css">        <span class="attribute">padding</span>: <span class="number">3px</span> <span class="number">8px</span>;</span></span><br><span class="line"><span class="language-css">        <span class="attribute">border-radius</span>: <span class="number">12px</span> <span class="number">0px</span> <span class="number">12px</span> <span class="number">0px</span>;</span></span><br><span class="line"><span class="language-css">        <span class="attribute">font-size</span>: <span class="number">12px</span>;</span></span><br><span class="line"><span class="language-css">        <span class="attribute">color</span>: white;</span></span><br><span class="line"><span class="language-css">        <span class="attribute">font-weight</span>: bold;</span></span><br><span class="line"><span class="language-css">        <span class="attribute">transition</span>: font-size <span class="number">0.3s</span> ease-out, width <span class="number">0.3s</span> ease-out, opacity <span class="number">0.3s</span> ease-out;</span></span><br><span class="line"><span class="language-css">    }</span></span><br><span class="line"><span class="language-css">    <span class="selector-class">.flink-list-item</span><span class="selector-pseudo">:hover</span> <span class="selector-class">.status-tag</span> {</span></span><br><span class="line"><span class="language-css">        <span class="attribute">font-size</span>: <span class="number">0px</span>;</span></span><br><span class="line"><span class="language-css">        <span class="attribute">opacity</span>: <span class="number">0</span>;</span></span><br><span class="line"><span class="language-css">    }</span></span><br><span class="line"><span class="language-css">    <span class="comment">/* 固态颜色 */</span></span></span><br><span class="line"><span class="language-css">    <span class="selector-class">.status-tag-green</span> {</span></span><br><span class="line"><span class="language-css">        <span class="attribute">background-color</span>: <span class="number">#005E00</span>; <span class="comment">/* 绿色 */</span></span></span><br><span class="line"><span class="language-css">    }</span></span><br><span class="line"><span class="language-css">    <span class="selector-class">.status-tag-light-yellow</span> {</span></span><br><span class="line"><span class="language-css">        <span class="attribute">background-color</span>: <span class="number">#FED101</span>; <span class="comment">/* 浅黄色 */</span></span></span><br><span class="line"><span class="language-css">    }</span></span><br><span class="line"><span class="language-css">    <span class="selector-class">.status-tag-dark-yellow</span> {</span></span><br><span class="line"><span class="language-css">        <span class="attribute">background-color</span>: <span class="number">#F0B606</span>; <span class="comment">/* 深黄色 */</span></span></span><br><span class="line"><span class="language-css">    }</span></span><br><span class="line"><span class="language-css">    <span class="selector-class">.status-tag-red</span> {</span></span><br><span class="line"><span class="language-css">        <span class="attribute">background-color</span>: <span class="number">#B90000</span>; <span class="comment">/* 红色 */</span></span></span><br><span class="line"><span class="language-css">    }</span></span><br><span class="line"><span class="language-css"></span><span class="tag">&lt;/<span class="name">style</span>&gt;</span></span><br><span class="line"><span class="tag">&lt;<span class="name">script</span>&gt;</span><span class="language-javascript"></span></span><br><span class="line"><span class="language-javascript"><span class="keyword">function</span> <span class="title function_">addStatusTagsWithCache</span>(<span class="params">jsonUrl</span>) {</span></span><br><span class="line"><span class="language-javascript">    <span class="keyword">const</span> cacheKey = <span class="string">"statusTagsData"</span>;</span></span><br><span class="line"><span class="language-javascript">    <span class="keyword">const</span> cacheExpirationTime = <span class="number">30</span> * <span class="number">60</span> * <span class="number">1000</span>; <span class="comment">// 半小时</span></span></span><br><span class="line"><span class="language-javascript">    <span class="keyword">function</span> <span class="title function_">applyStatusTags</span>(<span class="params">data</span>) {</span></span><br><span class="line"><span class="language-javascript">        <span class="keyword">const</span> linkStatus = data.<span class="property">link_status</span>;</span></span><br><span class="line"><span class="language-javascript">        <span class="variable language_">document</span>.<span class="title function_">querySelectorAll</span>(<span class="string">'.flink-list-item'</span>).<span class="title function_">forEach</span>(<span class="function"><span class="params">card</span> =&gt;</span> { <span class="comment">// 一定要注意这里的类名，小心匹配不上</span></span></span><br><span class="line"><span class="language-javascript">            <span class="keyword">if</span> (!card.<span class="property">href</span>) <span class="keyword">return</span>;</span></span><br><span class="line"><span class="language-javascript">            <span class="keyword">const</span> link = card.<span class="property">href</span>.<span class="title function_">replace</span>(<span class="regexp">/\/$/</span>, <span class="string">''</span>);</span></span><br><span class="line"><span class="language-javascript">            <span class="keyword">const</span> statusTag = <span class="variable language_">document</span>.<span class="title function_">createElement</span>(<span class="string">'div'</span>);</span></span><br><span class="line"><span class="language-javascript">            statusTag.<span class="property">classList</span>.<span class="title function_">add</span>(<span class="string">'status-tag'</span>);</span></span><br><span class="line"><span class="language-javascript">            <span class="keyword">let</span> matched = <span class="literal">false</span>;</span></span><br><span class="line"><span class="language-javascript">            <span class="comment">// 查找链接状态</span></span></span><br><span class="line"><span class="language-javascript">            <span class="keyword">const</span> status = linkStatus.<span class="title function_">find</span>(<span class="function"><span class="params">item</span> =&gt;</span> item.<span class="property">link</span>.<span class="title function_">replace</span>(<span class="regexp">/\/$/</span>, <span class="string">''</span>) === link);</span></span><br><span class="line"><span class="language-javascript">            <span class="keyword">if</span> (status) {</span></span><br><span class="line"><span class="language-javascript">                <span class="keyword">let</span> latencyText = <span class="string">'未知'</span>;</span></span><br><span class="line"><span class="language-javascript">                <span class="keyword">let</span> className = <span class="string">'status-tag-red'</span>; <span class="comment">// 默认红色</span></span></span><br><span class="line"><span class="language-javascript">                <span class="keyword">if</span> (status.<span class="property">latency</span> === -<span class="number">1</span>) {</span></span><br><span class="line"><span class="language-javascript">                    latencyText = <span class="string">'未知'</span>;</span></span><br><span class="line"><span class="language-javascript">                } <span class="keyword">else</span> {</span></span><br><span class="line"><span class="language-javascript">                    latencyText = status.<span class="property">latency</span>.<span class="title function_">toFixed</span>(<span class="number">2</span>) + <span class="string">' s'</span>;</span></span><br><span class="line"><span class="language-javascript">                    <span class="keyword">if</span> (status.<span class="property">latency</span> &lt;= <span class="number">2</span>) {</span></span><br><span class="line"><span class="language-javascript">                        className = <span class="string">'status-tag-green'</span>;</span></span><br><span class="line"><span class="language-javascript">                    } <span class="keyword">else</span> <span class="keyword">if</span> (status.<span class="property">latency</span> &lt;= <span class="number">5</span>) {</span></span><br><span class="line"><span class="language-javascript">                        className = <span class="string">'status-tag-light-yellow'</span>;</span></span><br><span class="line"><span class="language-javascript">                    } <span class="keyword">else</span> <span class="keyword">if</span> (status.<span class="property">latency</span> &lt;= <span class="number">10</span>) {</span></span><br><span class="line"><span class="language-javascript">                        className = <span class="string">'status-tag-dark-yellow'</span>;</span></span><br><span class="line"><span class="language-javascript">                    }</span></span><br><span class="line"><span class="language-javascript">                }</span></span><br><span class="line"><span class="language-javascript">                statusTag.<span class="property">textContent</span> = latencyText;</span></span><br><span class="line"><span class="language-javascript">                statusTag.<span class="property">classList</span>.<span class="title function_">add</span>(className);</span></span><br><span class="line"><span class="language-javascript">                matched = <span class="literal">true</span>;</span></span><br><span class="line"><span class="language-javascript">            }</span></span><br><span class="line"><span class="language-javascript">            <span class="keyword">if</span> (matched) {</span></span><br><span class="line"><span class="language-javascript">                card.<span class="property">style</span>.<span class="property">position</span> = <span class="string">'relative'</span>;</span></span><br><span class="line"><span class="language-javascript">                card.<span class="title function_">appendChild</span>(statusTag);</span></span><br><span class="line"><span class="language-javascript">            }</span></span><br><span class="line"><span class="language-javascript">        });</span></span><br><span class="line"><span class="language-javascript">    }</span></span><br><span class="line"><span class="language-javascript">    <span class="keyword">function</span> <span class="title function_">fetchDataAndUpdateUI</span>(<span class="params"></span>) {</span></span><br><span class="line"><span class="language-javascript">        <span class="title function_">fetch</span>(jsonUrl)</span></span><br><span class="line"><span class="language-javascript">            .<span class="title function_">then</span>(<span class="function"><span class="params">response</span> =&gt;</span> response.<span class="title function_">json</span>())</span></span><br><span class="line"><span class="language-javascript">            .<span class="title function_">then</span>(<span class="function"><span class="params">data</span> =&gt;</span> {</span></span><br><span class="line"><span class="language-javascript">                <span class="title function_">applyStatusTags</span>(data);</span></span><br><span class="line"><span class="language-javascript">                <span class="keyword">const</span> cacheData = {</span></span><br><span class="line"><span class="language-javascript">                    <span class="attr">data</span>: data,</span></span><br><span class="line"><span class="language-javascript">                    <span class="attr">timestamp</span>: <span class="title class_">Date</span>.<span class="title function_">now</span>()</span></span><br><span class="line"><span class="language-javascript">                };</span></span><br><span class="line"><span class="language-javascript">                <span class="variable language_">localStorage</span>.<span class="title function_">setItem</span>(cacheKey, <span class="title class_">JSON</span>.<span class="title function_">stringify</span>(cacheData));</span></span><br><span class="line"><span class="language-javascript">            })</span></span><br><span class="line"><span class="language-javascript">            .<span class="title function_">catch</span>(<span class="function"><span class="params">error</span> =&gt;</span> <span class="variable language_">console</span>.<span class="title function_">error</span>(<span class="string">'Error fetching test-flink result.json:'</span>, error));</span></span><br><span class="line"><span class="language-javascript">    }</span></span><br><span class="line"><span class="language-javascript">    <span class="keyword">const</span> cachedData = <span class="variable language_">localStorage</span>.<span class="title function_">getItem</span>(cacheKey);</span></span><br><span class="line"><span class="language-javascript">    <span class="keyword">if</span> (cachedData) {</span></span><br><span class="line"><span class="language-javascript">        <span class="keyword">const</span> { data, timestamp } = <span class="title class_">JSON</span>.<span class="title function_">parse</span>(cachedData);</span></span><br><span class="line"><span class="language-javascript">        <span class="keyword">if</span> (<span class="title class_">Date</span>.<span class="title function_">now</span>() - timestamp &lt; cacheExpirationTime) {</span></span><br><span class="line"><span class="language-javascript">            <span class="title function_">applyStatusTags</span>(data);</span></span><br><span class="line"><span class="language-javascript">            <span class="keyword">return</span>;</span></span><br><span class="line"><span class="language-javascript">        }</span></span><br><span class="line"><span class="language-javascript">    }</span></span><br><span class="line"><span class="language-javascript">    <span class="title function_">fetchDataAndUpdateUI</span>();</span></span><br><span class="line"><span class="language-javascript">}</span></span><br><span class="line"><span class="language-javascript"><span class="built_in">setTimeout</span>(<span class="function">() =&gt;</span> {</span></span><br><span class="line"><span class="language-javascript">    <span class="title function_">addStatusTagsWithCache</span>(<span class="string">'https://check.zeabur.app/result.json'</span>);</span></span><br><span class="line"><span class="language-javascript">}, <span class="number">0</span>);</span></span><br><span class="line"><span class="language-javascript"></span><span class="tag">&lt;/<span class="name">script</span>&gt;</span></span><br></pre></td></tr></tbody></table></figure><p>这段代码是一个JavaScript脚本，它定义了一个名为<code>addStatusTagsWithCache</code>的函数，该函数用于在网页上的链接卡片上添加状态标签。</p><ol><li><p><strong>CSS样式定义</strong>：首先定义了一个<code>.status-tag</code>的CSS类，这个类为状态标签设置了样式，包括绝对定位、填充、边框圆角、字体大小、颜色和字体粗细。</p></li><li><p><strong>JavaScript函数定义</strong>：定义了一个<code>addStatusTagsWithCache</code>函数，该函数接收一个参数<code>jsonUrl</code>，这个参数是一个JSON格式的URL，用于获取链接状态数据。</p></li><li><p><strong>缓存机制</strong>：函数内部使用<code>localStorage</code>来实现缓存机制，通过<code>cacheKey</code>和<code>cacheExpirationTime</code>来存储和控制缓存数据的有效期，减少对于<code>api</code>的请求次数并减少通信延迟。</p></li><li><p><strong>数据获取与UI更新</strong>：<code>fetchDataAndUpdateUI</code>是一个内部函数，用于从提供的URL获取数据，并更新页面上的UI。它首先使用<code>fetch</code> API请求JSON数据，然后解析数据，并根据数据中的可访问链接和不可访问链接列表，为页面上的<code>.site-card</code>元素添加状态标签。</p></li><li><p><strong>状态标签样式</strong>：根据链接的状态，状态标签的文本和背景颜色会有所不同。如果链接是可访问的，则文本为“正常”，背景颜色为绿色；如果链接是不可访问的，则文本为“疑问”，背景颜色为红色。</p></li><li><p><strong>缓存检查</strong>：在执行<code>fetchDataAndUpdateUI</code>之前，脚本会检查是否存在有效的缓存数据。如果缓存数据存在并且未过期，则直接使用缓存数据更新UI，否则调用<code>fetchDataAndUpdateUI</code>来获取最新数据。</p></li><li><p><strong>延迟执行</strong>：使用<code>setTimeout</code>函数延迟执行<code>addStatusTagsWithCache</code>函数，确保在页面加载完成后再执行此函数。</p></li><li><p><strong>实际URL调用</strong>：最后，脚本通过调用<code>addStatusTagsWithCache</code>函数，并传入实际的JSON URL（’<a target="_blank" rel="external nofollow noopener noreferrer" href="/safego/?u=aHR0cHM6Ly9jaGVjay56ZWFidXIuYXBwL3Jlc3VsdC5qc29uJyVFRiVCQyU4OSVFRiVCQyU4QyVFNiU5RCVBNSVFNSU5MCVBRiVFNSU4QSVBOCVFNiU5NSVCNCVFNCVCOCVBQSVFNiVCNSU4MSVFNyVBOCU4QiVFMyU4MCU4Mg">https://check.zeabur.app/result.json'），来启动整个流程。</a></p></li></ol><p>整个脚本的目的是动态地根据服务器返回的链接状态数据，在页面上为每个链接卡片添加相应的状态标签，以提示用户链接的当前状态。同时，通过使用缓存机制，可以减少对服务器的请求次数，提高页面性能。</p><p>最终展示图如下：</p><p><img src="" data-lazy-src="https://p.liiiu.cn/i/2024/06/23/667839ccb1596.webp" alt="友链页面"></p><h2 id="缺陷"><a href="#缺陷" class="headerlink" title="缺陷"></a>缺陷</h2><ol><li><strong>网络延迟</strong>：网络延迟会影响请求的响应时间，特别是当检测的链接位于地理位置较远或网络条件较差的服务器上时（已解决）。</li><li><strong>国外网络环境限制</strong>：如果GitHub Actions的服务器位于国外，可能会因为某些国家或地区的网络审查制度而无法访问部分网站（已解决）。</li><li><strong>Python检测缺陷</strong>：使用Python的<code>requests</code>库进行检测可能无法完全模拟浏览器行为，例如，它可能无法处理JavaScript渲染的页面或执行某些客户端脚本（已解决）。</li><li><strong>请求限制</strong>：某些网站可能会对频繁的请求进行限制，导致GitHub Actions的IP地址被暂时或永久地封禁（已解决）。</li><li><strong>HTTP头信息</strong>：使用<code>head</code>方法虽然可以获取页面的元数据，但不会获取到页面的实际内容，这可能导致一些需要分析页面内容才能判断的可访问性问题被忽略（已解决）。</li><li><strong>HTTPS证书问题</strong>：如果检测的链接使用自签名证书或不受信任的证书，<code>requests</code>可能会抛出警告或错误，导致检测失败（已解决）。</li><li><strong>重定向处理</strong>：某些链接可能会进行重定向，如果脚本没有正确处理重定向，可能会误判链接的状态。</li></ol><h2 id="总结"><a href="#总结" class="headerlink" title="总结"></a>总结</h2><p>虽然这个方式有缺陷，但也在很大程度上减少了我们的工作量，可以不用手动一个个检测了。自动化的检测流程不仅节约了大量时间，还提高了检测的一致性和准确性。通过脚本，我们可以快速地对大量链接进行批量检查，及时地发现问题并进行相应的处理。此外，自动化测试可以很容易地集成到持续集成/持续部署（CI/CD）的流程中，确保在软件开发周期的早期阶段就能识别和修复问题。尽管存在一些局限性，但通过适当的配置和优化，我们可以最大限度地减少这些缺陷的影响，同时享受自动化带来的便利。</p><h2 id="每日一图"><a href="#每日一图" class="headerlink" title="每日一图"></a>每日一图</h2><p><img src="" data-lazy-src="https://p.liiiu.cn/i/2024/06/23/66783acba4040.webp" alt="咕咕！"></p><h2 id="参考链接"><a href="#参考链接" class="headerlink" title="参考链接"></a>参考链接</h2><div class="liushen-tag-link"><a class="tag-Link" target="_blank" href="/safego/?u=aHR0cHM6Ly9naXRodWIuY29tL3NoYW5nc2tyL2J1dHRlcmZseS1jaGVjay1saW5rcw" rel="external nofollow noopener noreferrer"><div class="tag-link-tips">🙄引用站外地址，不保证站点的可用性和安全性</div><div class="tag-link-bottom"><div class="tag-link-left" style="background-image:url(https://p.liiiu.cn/i/2024/07/27/66a461a3098aa.webp)"></div><div class="tag-link-right"><div class="tag-link-title">Butterfly-check-links</div><div class="tag-link-sitename">github.com@shangkr</div></div><i class="fa-solid fa-angle-right"></i></div></a></div><div class="liushen-tag-link"><a class="tag-Link" target="_blank" href="/safego/?u=aHR0cHM6Ly9oZXhvLnNoYW5nc2tyLnRvcC9wb3N0cy8yMC5odG1s" rel="external nofollow noopener noreferrer"><div class="tag-link-tips">🙄引用站外地址，不保证站点的可用性和安全性</div><div class="tag-link-bottom"><div class="tag-link-left" style="background-image:url(https://p.liiiu.cn/i/2024/07/27/66a4632bbf06e.webp)"></div><div class="tag-link-right"><div class="tag-link-title">Butterfly主题友情链接可用性检测</div><div class="tag-link-sitename">安·SKR·|·shangskr.top</div></div><i class="fa-solid fa-angle-right"></i></div></a></div><div class="liushen-tag-link"><a class="tag-Link" target="_blank" href="/safego/?u=aHR0cHM6Ly9ibG9nLnpoaGVvLmNvbS9wL2JhYTZiMThiLmh0bWw" rel="external nofollow noopener noreferrer"><div class="tag-link-tips">🙄引用站外地址，不保证站点的可用性和安全性</div><div class="tag-link-bottom"><div class="tag-link-left" style="background-image:url(https://p.liiiu.cn/i/2024/07/27/66a4632bbf06e.webp)"></div><div class="tag-link-right"><div class="tag-link-title">Python一键检查Butterfly主题友情链接可用性脚本</div><div class="tag-link-sitename">张洪HEO·|·zhheo.com</div></div><i class="fa-solid fa-angle-right"></i></div></a></div><p><em>— 柳影曳曳，清酒孤灯，扬笔撒墨，心境如霜</em></p></article><div class="post-copyright"><div class="post-copyright__title"><span class="post-copyright-info"><h>Github Action实现友链状态检测</h></span></div><div class="post-copyright__type"><span class="post-copyright-info"><a href="https://blog.liushen.fun/posts/c2262998/">https://blog.liushen.fun/posts/c2262998/</a></span></div><div class="post-copyright-m"><div class="post-copyright-m-info" style="position:relative;z-index:3"><div class="post-copyright-a" style="display:inline-block;width:fit-content;margin:20px 20px 20px 0"><h>作者</h><div class="post-copyright-cc-info"><h>LiuShen</h></div></div><div class="post-copyright-c" style="display:inline-block;width:fit-content;margin:20px 20px 20px 0"><h>发布于</h><div class="post-copyright-cc-info"><h>2024-06-24</h></div></div><div class="post-copyright-u" style="display:inline-block;width:fit-content;margin:20px 20px 20px 0"><h>更新于</h><div class="post-copyright-cc-info"><h>2024-09-20</h></div></div><div class="post-copyright-c" style="display:inline-block;width:fit-content;margin:20px 20px 20px 0"><h>许可协议</h><div class="post-copyright-cc-info"><a rel="noopener" target="_blank" title=" CC BY 4.0" href="https://creativecommons.org/licenses/by-nc-sa/4.0/?ref=chooser-v1">CC BY-NC-SA 4.0</a></div></div></div></div></div><div class="tag_share"><div class="post-meta__tag-list"><a class="post-meta__tags" href="/tags/Hexo/">Hexo</a><a class="post-meta__tags" href="/tags/%E7%8A%B6%E6%80%81%E6%A3%80%E6%B5%8B/">状态检测</a></div><div class="post-share"><div class="social-share" data-image="https://p.liiiu.cn/i/2024/06/23/6676f5b705711.webp" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://jsd.liiiu.cn/npm/butterfly-extsrc@1.1.4/sharejs/dist/css/share.min.css" media="print" onload='this.media="all"'><script src="https://jsd.liiiu.cn/npm/butterfly-extsrc@1.1.4/sharejs/dist/js/social-share.min.js" defer></script></div></div><div class="post-reward"><div class="reward-button"><i class="fas fa-qrcode"></i>来😍鼠标过来一点~</div><div class="reward-main"><ul class="reward-all"><li class="reward-item"><a href="/config/img/wechat.png" target="_blank"><img class="post-qr-code-img" src="" data-lazy-src="/config/img/wechat.png" alt="微信"></a><div class="post-qr-code-desc">微信</div></li><li class="reward-item"><a href="/config/img/wechat.png" target="_blank"><img class="post-qr-code-img" src="" data-lazy-src="/config/img/wechat.png" alt="支付宝"></a><div class="post-qr-code-desc">支付宝</div></li></ul></div></div><nav class="pagination-post" id="pagination"><a class="prev-post pull-left" href="/posts/1dfd1f41/" title="安全跳转页面·插件版"><img class="cover" src="" data-lazy-src="https://p.liiiu.cn/i/2024/06/17/666f1ec25d642.webp" onerror='onerror=null,src="/img/404.jpg"' alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info">安全跳转页面·插件版</div></div></a><a class="next-post pull-right" href="/posts/13e6e155/" title="东软软件园实习日记"><img class="cover" src="" data-lazy-src="https://p.liiiu.cn/i/2024/07/01/66823117502e0.webp" onerror='onerror=null,src="/img/404.jpg"' alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info">东软软件园实习日记</div></div></a></nav><div class="relatedPosts"><div class="headline"><i class="fas fa-thumbs-up fa-fw"></i><span>相关推荐</span></div><div class="relatedPosts-list"><a href="/posts/7e3de29e/" title="小白的网站部署之路"><img class="cover" src="" data-lazy-src="https://p.liiiu.cn/i/2024/03/25/6600e02f2cecb.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2024-03-15</div><div class="title">小白的网站部署之路</div></div></a><a href="/posts/1dfd1f41/" title="安全跳转页面·插件版"><img class="cover" src="" data-lazy-src="https://p.liiiu.cn/i/2024/06/17/666f1ec25d642.webp" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2024-06-17</div><div class="title">安全跳转页面·插件版</div></div></a><a href="/posts/9efc1657/" title="安全跳转页面·重制版"><img class="cover" src="" data-lazy-src="https://p.liiiu.cn/i/2024/04/20/6623e50e7b7d2.png" alt="cover"><div class="content is-center"><div class="date"><i class="far fa-calendar-alt fa-fw"></i> 2024-04-21</div><div class="title">安全跳转页面·重制版</div></div></a></div></div><hr class="custom-hr"><div id="post-comment"><div class="comment-head"><div class="comment-headline"><i class="fas fa-comments fa-fw"></i> <span>评论</span></div></div><div class="comment-wrap"><div><div id="artalk-wrap"></div></div></div></div></div><div class="aside-content" id="aside-content"><div class="card-widget card-info is-center"><div class="author-info-detail"><p class="author-info-hello">👋 欢迎光临！</p><p class="author-info-desc">你们好呀！我是站长LiuShen！一个快乐，积极，热爱生活的孩纸！😜😜😜</p></div><div class="avatar-img"><img class="mood-icon" src="" data-lazy-src="https://p.liiiu.cn/i/2025/03/14/67d301461a24a.webp" alt="🤤" onerror='this.onerror=null,this.src="/img/friend_404.gif"'><img src="" data-lazy-src="https://p.liiiu.cn/i/2025/03/13/67d2fc82d329c.webp" onerror='this.onerror=null,this.src="/img/friend_404.gif"' alt="avatar"></div><div class="author-info-name">LiuShen</div><div class="site-data"><a href="/archives/"><div class="headline">文章</div><div class="length-num">72</div></a><a href="/tags/"><div class="headline">标签</div><div class="length-num">98</div></a><a href="/categories/"><div class="headline">分类</div><div class="length-num">3</div></a></div><a id="card-info-btn" target="_blank" rel="noopener" href="https://github.com/willow-god"><i class="fab fa-github"></i><span>Follow Me 🛫</span></a><div class="card-info-social-icons"><a class="social-icon" href="mailto:01@liushen.fun" target="_blank" title="Email"><i class="fa-solid fa-envelope"></i></a><a class="social-icon" href="http://wpa.qq.com/msgrd?v=3&amp;uin=3162475700&amp;site=qq&amp;menu=yes" target="_blank" title="QQ：3162475700"><i class="fa-brands fa-qq"></i></a><a class="social-icon" href="https://wakatime.com/@LiuShen" target="_blank" title="Wakatime"><i class="fa-solid fa-chart-column"></i></a><a class="social-icon" href="https://blog.liushen.fun/atom.xml" target="_blank" title="rss地址"><i class="fa-solid fa-rss"></i></a></div></div><div class="card-widget" id="card-poem"><div id="poem_sentence"></div><div id="poem_info"><div id="poem_dynasty"></div><div id="poem_author"></div></div></div><script src="/js/jinrishici.js" charset="utf-8"></script><script>jinrishici.load((function(e){var n=document.querySelector("#poem_sentence"),t=document.querySelector("#poem_author"),o=document.querySelector("#poem_dynasty"),r=e.data.content;r=r.substr(0,r.length-1),n.innerHTML=r,o.innerHTML=e.data.origin.dynasty,t.innerHTML=e.data.origin.author+"《"+e.data.origin.title+"》"}))</script><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn fa-shake"></i><span>公告</span></div><div class="announcement_content"><p><strong>博客架构概览：</strong><br>⚙️框架核心：Hexo<br>🕹️界面设计：Butterfly<br>🔮安全保障：长亭雷池<br>🔩管理工具：宝塔面板，1Panel<br>🎰服务器支持：阿里云，腾讯云<br>🎲CDN加速：多吉云，CloudFlare<br><strong>快捷跳转地址：</strong><br>🧩个人相册：<a target="_blank" rel="noopener" href="https://xc.liushen.fun">xc.liushen.fun</a><br>🤖个人导航：<a target="_blank" rel="noopener" href="https://www.liushen.fun">www.liushen.fun</a><br></p><img src="" data-lazy-src="/config/img/notice.gif" alt="可爱捏" title="可爱捏" style="width:100%;border-radius:10px"></div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span><span class="toc-percentage"></span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#%E7%A2%8E%E7%A2%8E%E5%BF%B5"><span class="toc-text">碎碎念</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%8A%9F%E8%83%BD%E6%A6%82%E8%A7%88"><span class="toc-text">功能概览</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E4%BD%BF%E7%94%A8%E6%95%99%E7%A8%8B"><span class="toc-text">使用教程</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#github%E9%85%8D%E7%BD%AE"><span class="toc-text">github配置</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E8%8E%B7%E5%8F%96%E6%96%B9%E5%BC%8F"><span class="toc-text">获取方式</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#%E5%8A%A8%E6%80%81Json%E8%8E%B7%E5%8F%96"><span class="toc-text">动态Json获取</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E9%9D%99%E6%80%81csv%E8%8E%B7%E5%8F%96"><span class="toc-text">静态csv获取</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E6%8F%90%E5%8D%87%E5%87%86%E7%A1%AE%E7%8E%87"><span class="toc-text">提升准确率</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E9%83%A8%E7%BD%B2%E5%B1%95%E7%A4%BA%E9%A1%B5%E9%9D%A2"><span class="toc-text">部署展示页面</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#%E5%B0%86%E6%95%B0%E6%8D%AE%E5%B1%95%E7%A4%BA%E5%88%B0%E5%89%8D%E7%AB%AF"><span class="toc-text">将数据展示到前端</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#%E9%80%9A%E7%94%A8%E8%A7%A3%E9%87%8A"><span class="toc-text">通用解释</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E6%9C%AC%E7%AB%99%E6%96%B9%E6%A1%88"><span class="toc-text">本站方案</span></a></li></ol></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E7%BC%BA%E9%99%B7"><span class="toc-text">缺陷</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%80%BB%E7%BB%93"><span class="toc-text">总结</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E6%AF%8F%E6%97%A5%E4%B8%80%E5%9B%BE"><span class="toc-text">每日一图</span></a></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%8F%82%E8%80%83%E9%93%BE%E6%8E%A5"><span class="toc-text">参考链接</span></a></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/posts/7915ee6b/" title="数据库可视化WEB工具对比"><img src="" data-lazy-src="https://p.liiiu.cn/i/2025/05/25/6832cc105bc41.webp" onerror='this.onerror=null,this.src="/img/404.jpg"' alt="数据库可视化WEB工具对比"></a><div class="content"><a class="title" href="/posts/7915ee6b/" title="数据库可视化WEB工具对比">数据库可视化WEB工具对比</a><time datetime="2025-05-25T10:01:21.000Z" title="更新于 2025-05-25 18:01:21">2025-05-25</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/posts/40702a0d/" title="本地实现HEXO文章AI摘要"><img src="" data-lazy-src="https://p.liiiu.cn/i/2025/05/06/6819cd4532457.webp" onerror='this.onerror=null,this.src="/img/404.jpg"' alt="本地实现HEXO文章AI摘要"></a><div class="content"><a class="title" href="/posts/40702a0d/" title="本地实现HEXO文章AI摘要">本地实现HEXO文章AI摘要</a><time datetime="2025-05-06T16:01:21.000Z" title="更新于 2025-05-07 00:01:21">2025-05-07</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/posts/5f71a4b1/" title="耗子面板和DPanel简单体验"><img src="" data-lazy-src="https://p.liiiu.cn/i/2025/04/27/680dc7916ef34.webp" onerror='this.onerror=null,this.src="/img/404.jpg"' alt="耗子面板和DPanel简单体验"></a><div class="content"><a class="title" href="/posts/5f71a4b1/" title="耗子面板和DPanel简单体验">耗子面板和DPanel简单体验</a><time datetime="2025-04-28T14:48:21.000Z" title="更新于 2025-04-28 22:48:21">2025-04-28</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/posts/caee2d9f/" title="美化你的RSS订阅地址"><img src="" data-lazy-src="https://p.liiiu.cn/i/2025/04/18/68024a618942b.webp" onerror='this.onerror=null,this.src="/img/404.jpg"' alt="美化你的RSS订阅地址"></a><div class="content"><a class="title" href="/posts/caee2d9f/" title="美化你的RSS订阅地址">美化你的RSS订阅地址</a><time datetime="2025-04-18T12:48:21.000Z" title="更新于 2025-04-18 20:48:21">2025-04-18</time></div></div></div></div></div></div></main><footer id="footer"><div id="footer-wrap" style="background:0 0"><div id="footer_icons"><div><a class="icon_link" rel="noopener external nofollow" href="https://www.liushen.fun/" title="导航站点" target="_blank"><i class="fa-solid fa-compass"></i></a><a class="icon_link" rel="noopener external nofollow" href="https://admin.qidian.qq.com/static_proxy/b2b-qq/wpa-link/index.html#/person?uin=3162475700" title="联系QQ" target="_blank"><i class="fa-brands fa-qq"></i></a><a class="icon_link" rel="noopener external nofollow" href="https://github.com/willow-god" title="我的github主页" target="_blank"><i class="fa-brands fa-github"></i></a><a class="icon_link" rel="noopener external nofollow" href="mailto:01@liushen.fun" title="发送邮件至博主邮箱" target="_blank"><i class="fa-solid fa-envelope"></i></a></div><div class="footer_logo_container" onclick="btf.scrollToDest(0,500)" title="返回顶部"><img class="footer_logo" src="" data-lazy-src="/img/footer.gif"></div><div><a class="icon_link" rel="noopener external nofollow" href="https://wakatime.com/@LiuShen" title="Wikitime" target="_blank"><i class="fa-solid fa-clock"></i></a><a class="icon_link" rel="noopener external nofollow" href="https://gitlab.com/" title="gitlab" target="_blank"><i class="fa-brands fa-gitlab"></i></a><a class="icon_link" href="/shuoshuo/" title="日常说说" data-pjax-state="data-pjax-state"><i class="fa-solid fa-file-pen"></i></a><a class="icon_link" href="/comment/" title="留言板" data-pjax-state="data-pjax-state"><i class="fa-solid fa-comment"></i></a></div></div><div id="footer_content"><div class="footer-group"><h3 class="footer-title">关于本站</h3><div class="footer-links"><a class="footer-item" target="_blank" href="https://www.liushen.fun/">导航站点</a><a class="footer-item" href="/shuoshuo/">日常说说</a><a class="footer-item" target="_blank" href="https://um.liushen.fun/share/bIEnQp0xnMxD8c9V/blog.liushen.fun">访客信息</a><a class="footer-item" target="_blank" href="https://mm.liushen.fun/">提笔摘星</a><a class="footer-item" target="_blank" href="https://status.liushen.fun/">在线状态</a><a class="footer-item" href="/subscribe/">订阅本站</a></div></div><div class="footer-group"><h3 class="footer-title">加入组织</h3><div class="footer-links"><a class="footer-item" target="_blank" href="https://www.boyouquan.com/home">博友圈</a><a class="footer-item" target="_blank" href="https://github.com/timqian/chinese-independent-blogs">中博列表</a><a class="footer-item" target="_blank" href="https://blogwe.com/">博客我们</a><a class="footer-item" target="_blank" href="https://storeweb.cn/">个性商店</a><a class="footer-item" target="_blank" href="https://bf.zzxworld.com/">发现博客</a><a class="footer-item" target="_blank" href="https://ourblo.gs/">OurBlogs</a></div></div><div class="footer-group"><h3 class="footer-title">文章整理</h3><div class="footer-links"><a class="footer-item" href="/categories/website/">博客管理</a><a class="footer-item" href="/categories/learning/">学习资料</a><a class="footer-item" href="/categories/daily-share/">日常分享</a><a class="footer-item" href="/archives/">时光卷轴</a><a class="footer-item" href="/charts/">文章通览</a><a class="footer-item" href="/categories/">查看全部</a></div></div><div class="footer-group"><h3 class="footer-title">文章标签</h3><div class="footer-links"><a class="footer-item" href="/tags/JavaScript/">JS知识</a><a class="footer-item" href="/tags/Hexo/">本站框架</a><a class="footer-item" href="/tags/机器学习/">机器学习</a><a class="footer-item" href="/tags/日记/">个人日记</a><a class="footer-item" href="/tags/CSS/">CSS知识</a><a class="footer-item" href="/tags/">查看全部</a></div></div><div class="footer-group"><h3 class="footer-title">自建工具</h3><div class="footer-links"><a class="footer-item" target="_blank" rel="noopener" href="https://chat.liushen.fun/">清羽AI</a><a class="footer-item" target="_blank" rel="noopener" href="https://hot.liushen.fun/">今日热榜</a><a class="footer-item" target="_blank" rel="noopener" href="https://cover.qyliu.top/">封面设计</a><a class="footer-item" target="_blank" rel="noopener" href="https://icon.qyliu.top/">万变图标</a><a class="footer-item" target="_blank" rel="noopener" href="https://tmail.qyliu.top/">临时邮箱</a><a class="footer-item" target="_blank" rel="noopener" href="https://share.liushen.fun/">内容中转</a></div></div><div class="footer-group" id="friend-links-in-footer"><h3 class="footer-title">友链<button title="换一批" href="javascript:;" onclick="liushen.randomLink()"><i class="fa-solid fa-rotate-right"></i></button></h3><div class="footer-links"><a class="footer-item" target="_blank" href="https://blog.liushen.fun">测试1</a><a class="footer-item" target="_blank" href="https://blog.liushen.fun">测试2</a><a class="footer-item" target="_blank" href="https://blog.liushen.fun">测试3</a><a class="footer-item" target="_blank" href="https://blog.liushen.fun">测试4</a><a class="footer-item" target="_blank" href="https://blog.liushen.fun">测试5</a><a class="footer-item" href="/link/" data-pjax-state="data-pjax-state">查看更多</a></div></div></div><div id="footer-bottom"><div class="footer-bottom-content"><div class="footer-bottom-left"><span class="copyright">©2021 - 2025 By <a target="_blank" rel="noopener" href="https://blog.liushen.fun/about/" title="点击访问&quot;LiuShen&quot;的主页" style="margin-left:5px">LiuShen</a></span><div><a class="footer-bottom-link" target="_blank" href="https://beian.miit.gov.cn/" rel="noopener external nofollow" title="工信部备案号">陕ICP备2024028531号-2</a><a class="footer-bottom-link" target="_blank" href="https://beian.mps.gov.cn/#/query/webSearch?code=61011602000637" rel="noopener external nofollow" title="公安备案号">陕公网安备61011602000637号</a></div></div><div class="footer-bottom-right"><div id="runtime" title="本站运行时间">本站已苟活：0 天 0 时 0 分 0 秒</div><div><a class="footer-bottom-link" target="_blank" href="https://www.dogecloud.com/?iuid=9173" rel="noopener external nofollow" title="本站通过多吉云CDN提供站点加速">多吉云CDN</a><a class="footer-bottom-link" target="_blank" href="https://hexo.io/zh-cn/" rel="noopener external nofollow" title="本站使用Hexo架构搭建而成">Hexo静态框架</a><a class="footer-bottom-link" target="_blank" href="https://butterfly.js.org/" rel="noopener external nofollow" title="本站主题由Butterfly主题魔改而成">LiuShen主题</a></div></div></div></div></div><script>window.liushen||(window.liushen={saveData:(e,n)=>{localStorage.setItem(e,JSON.stringify({time:Date.now(),data:n}))},loadData:(e,n)=>{let t=JSON.parse(localStorage.getItem(e));if(t){let e=Date.now()-t.time;if(e>=0&&e<6e4*n)return t.data}return null},runtime:()=>{const e=e=>e>9?e:"0"+e,n=new Date("2021/12/12 01:27:36").getTime(),t=Date.now();let i=Math.round((t-n)/1e3),o="本站已苟活：";i>=86400&&(o+=`${e(Math.floor(i/86400))} 天 `,i%=86400),i>=3600&&(o+=`${e(Math.floor(i/3600))} 时 `,i%=3600),i>=60&&(o+=`${e(Math.floor(i/60))} 分 `,i%=60),o+=`${e(i)} 秒`;const l=document.getElementById("runtime");l&&(l.innerHTML=o),setTimeout(window.liushen.runtime,1e3)},randomLink:()=>{let e=window.liushen.loadData("links",30);if(e){let n=document.querySelectorAll("#friend-links-in-footer .footer-item");if(!n.length)return;for(let t=0;t<n.length;t++){let i=Math.floor(Math.random()*e.length);n[t].innerText=e[i].name,n[t].href=e[i].link,e.splice(i,1)}}else fetch("/flink_count.json").then((e=>e.json())).then((e=>{window.liushen.saveData("links",e.link_list),window.liushen.randomLink()}))}}),window.liushen.randomLink(),document.addEventListener("DOMContentLoaded",window.liushen.randomLink),window.liushen.runtime()</script></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="translateLink" type="button" title="简繁转换" style="width:35px">繁</button><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i><span class="rightside-text">阅读模式</span></button><button id="darkmode" type="button" title="日间和夜间模式切换"><i class="fa-regular fa-star-half-stroke"></i><span class="rightside-text">亮暗切换</span></button><button id="cat" onclick="toggleLive2dVisibility()" title="小猫显隐"><i class="fa-solid fa-cat"></i><span class="rightside-text">小猫显隐</span></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fa-solid fa-arrows-left-right-to-line"></i><span class="rightside-text">侧栏显隐</span></button></div><div id="rightside-config-show"><button id="rightside-config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i><span class="rightside-text">更多设置</span></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i><span class="rightside-text">显示目录</span></button><button id="fullscreen" onclick="toggleFullScreen()" title="全屏切换"><i class="fa-solid fa-expand"></i><span class="rightside-text">全屏切换</span></button><a id="to_comment" href="#post-comment" title="前往评论"><i class="fas fa-comments"></i><span class="rightside-text">快速评论</span></a><button id="go-up" type="button" title="回到顶部"><span class="scroll-percent"></span><i class="fas fa-arrow-up"></i><span class="rightside-text">回到顶部</span></button></div></div><div id="rightMenu"><div class="rightMenu-group rightMenu-small"><div class="rightMenu-item" id="menu-backward"><i class="fa-solid fa-arrow-left"></i></div><div class="rightMenu-item" id="menu-forward"><i class="fa-solid fa-arrow-right"></i></div><div class="rightMenu-item" id="menu-refresh"><i class="fa-solid fa-arrow-rotate-right"></i></div><div class="rightMenu-item" id="menu-home"><i class="fa-solid fa-house"></i></div></div><div class="rightMenu-group rightMenu-line hide" id="menu-text"><a class="rightMenu-item" id="copy" href="javascript:rm.copySelect();"><i class="fa-solid fa-copy"></i><span>复制选中文字</span></a><a class="rightMenu-item" id="reply" href="javascript:rm.replySelect();"><i class="fa-regular fa-comment"></i><span>评论选中段落</span></a></div><div class="rightMenu-group rightMenu-line rightMenuOther"><a class="rightMenu-item menu-link" href="/archives/"><i class="fa-solid fa-archive"></i><span>文章时间线</span></a><a class="rightMenu-item menu-link" href="/categories/"><i class="fa-solid fa-folder-open"></i><span>文章分大类</span></a><a class="rightMenu-item menu-link" href="/tags/"><i class="fa-solid fa-tags"></i><span>文章小标签</span></a></div><div class="rightMenu-group rightMenu-line rightMenuNormal"><a class="rightMenu-item menu-link" id="menu-radompage" href="/comment/"><i class="fa-solid fa-shoe-prints"></i><span>随心留言板</span></a><div class="rightMenu-item" id="menu-translate"><i class="fa-solid fa-earth-asia"></i><span>繁简模式切换</span></div><div class="rightMenu-item" id="menu-live2dvisibility"><i class="fa-solid fa-cat"></i><span>小猫显示隐藏</span></div><div class="rightMenu-item" id="menu-print"><i class="fa-solid fa-print fa-fw"></i><span>打印整个页面</span></div><a class="rightMenu-item menu-link" id="statement" href="/statement/"><i class="fa-regular fa-copyright fa-fw"></i><span>网站声明</span></a></div></div><div id="rightmenu-mask"></div><div><script src="/js/others.js?v=5.0.0"></script><script src="/js/utils.js?v=5.0.0"></script><script src="/js/main.js?v=5.0.0"></script><script src="https://jsd.liiiu.cn/npm/echarts@5.5.1/dist/echarts.simple.min.js"></script><script src="/js/rightmenu.js?v=5.0.0"></script><script src="/js/jinrishici.js"></script><script src="/js/tw_cn.js?v=5.0.0"></script><script src="https://jsd.liiiu.cn/npm/@fancyapps/ui@5.0.36/dist/fancybox/fancybox.umd.min.js"></script><script src="https://jsd.liiiu.cn/npm/instant.page@5.2.0/instantpage.min.js" type="module"></script><script src="https://jsd.liiiu.cn/npm/vanilla-lazyload@19.1.3/dist/lazyload.iife.min.js"></script><div class="js-pjax"><script>(()=>{let t=null;const e=null,o="shuoshuo"===GLOBAL_CONFIG_SITE.pageType,a=()=>{t&&(t.destroy(),t=null)},n=e=>t&&t.setDarkMode("dark"===e),l=(l=document,i=location.pathname)=>{t=Artalk.init({el:l.querySelector("#artalk-wrap"),server:"https://atk.liushen.fun",site:"清羽飞扬",darkMode:"dark"===document.documentElement.getAttribute("data-theme"),...e,pageKey:i,imgUploader:function(t){let e="Bearer 28|q18njD3pLtHiFy9WidqQrREwqZzb8Zionr8WzilI",o="https://www.baiwulin.work/api/v1/upload",a=new Headers;a.set("Accept","application/json"),a.set("Authorization",e);let n=new FormData;n.append("file",t);const l=(t,e,o)=>fetch(t,{method:"POST",body:e,headers:o}).then((t=>t.json())).then((t=>t.data.links.url)).catch((t=>(console.error("Image upload failed:",t),null)));return l(o,n,a).then((t=>t||(console.warn("雾林图床接口失败，尝试替换为秋叶图床"),e="Bearer 11|lsReISlSS0dyhDzt35ovtfYefGbWSRW2vvntPXs7",o="https://imgse.koxiuqiu.cc/api/v1/upload",a.set("Authorization",e),l(o,n,a))))}}),"null"!==GLOBAL_CONFIG.lightbox&&(t.on("list-loaded",(()=>{t.ctx.get("list").getCommentNodes().forEach((t=>{const e=t.getRender().$content;btf.loadLightbox(e.querySelectorAll("img:not([atk-emoticon])"))}))})),o&&(window.shuoshuoComment.destroyArtalk=()=>{a(),l.children.length&&(l.innerHTML="",l.classList.add("no-comment"))}),btf.addGlobalFn("pjaxSendOnce",a,"destroyArtalk"),btf.addGlobalFn("themeChange",n,"artalk"))},i=async(t,e)=>{"object"==typeof Artalk||(await btf.getCSS("https://jsd.liiiu.cn/npm/artalk@2.9.1/dist/Artalk.min.css"),await btf.getScript("https://jsd.liiiu.cn/npm/artalk@2.9.1/dist/Artalk.min.js")),l(t,e)};o?window.shuoshuoComment={loadComment:i}:setTimeout(i,0)})()</script></div><script>window.newestComments={changeContent:e=>(""===e||(e=(e=(e=(e=(e=e.replace(/<img.*?src="(.*?)"?[^\>]+>/gi,"[图片]")).replace(/<a[^>]+?href=["']?([^"']+)["']?[^>]*>([^<]+)<\/a>/gi,"[链接]")).replace(/<pre><code>.*?<\/pre>/gi,"[代码]")).replace(/<code>.*?<\/code>/gi,"[代码]")).replace(/<[^>]+>/g,"")).length>150&&(e=e.substring(0,150)+"..."),e),generateHtml:(e,t)=>{let n="";if(e.length)for(let t=0;t<e.length;t++){if(n+='<div class="aside-list-item">',e[t].avatar){const a="data-lazy-src";n+=`<a href="${e[t].url}" class="thumbnail"><img ${a}="${e[t].avatar}" alt="${e[t].nick}"></a>`}n+=`<div class="content">\n        <a class="comment" href="${e[t].url}" title="${e[t].content}">${e[t].content}</a>\n        <div class="name"><span>${e[t].nick} / </span><time datetime="${e[t].date}">${btf.diffDate(e[t].date,!0)}</time></div>\n        </div></div>`}else n+="暂无评论";t.innerHTML=n,window.lazyLoadInstance&&window.lazyLoadInstance.update(),window.pjax&&window.pjax.refresh(t)},newestCommentInit:(e,t)=>{const n=document.querySelector("#card-newest-comments .aside-list");if(n){const a=btf.saveToLocal.get(e);a?newestComments.generateHtml(JSON.parse(a),n):t(n)}},run:(e,t)=>{newestComments.newestCommentInit(e,t),btf.addGlobalFn("pjaxComplete",(()=>newestComments.newestCommentInit(e,t)),e)}}</script><script>window.addEventListener("load",(()=>{const t="artalk-newest-comments",{changeContent:a,generateHtml:e,run:n}=window.newestComments,r=new URLSearchParams({site_name:"清羽飞扬",limit:"5"});n(t,(async n=>{try{const s=await fetch(`https://atk.liushen.fun/api/v2/stats/latest_comments?${r}`),o=await s.json(),{avatarCdn:c,avatarDefault:i}=await(async()=>{const t=t=>t.startsWith("d=")?t:`d=${t}`;try{const a=await fetch("https://atk.liushen.fun/api/v2/conf"),e=await a.json(),{mirror:n,params:r,default:s}=e.frontend_conf.gravatar;return{avatarCdn:n,avatarDefault:t(r||s)}}catch(a){return console.error(a),{avatarCdn:"",avatarDefault:t("")}}})(),l=o.data.map((t=>({avatar:c&&t.email_encrypted?`${c}${t.email_encrypted}?${i}`:"",content:a(t.content_marked),nick:t.nick,url:t.page_url,date:t.date})));btf.saveToLocal.set(t,JSON.stringify(l),10/1440),e(l,n)}catch(t){console.log(t),n.textContent="无法获取评论，请确认相关配置是否正确"}}))}))</script><script src="/config/memos/memos.js"></script><script id="canvas_nest" defer color="128,128,128" opacity="0.7" zindex="-1" count="99" mobile="false" src="https://jsd.liiiu.cn/npm/butterfly-extsrc@1.1.4/dist/canvas-nest.min.js"></script><link rel="stylesheet" href="https://jsd.liiiu.cn/npm/aplayer@1.10.1/dist/APlayer.min.css" media="print" onload='this.media="all"'><script src="https://jsd.liiiu.cn/npm/aplayer@1.10.1/dist/APlayer.min.js"></script><script src="https://jsd.liiiu.cn/npm/meting@2.0.1/dist/Meting.min.js"></script><script src="https://jsd.liiiu.cn/npm/pjax@0.2.8/pjax.min.js"></script><script>(()=>{window.pjax=new Pjax({elements:'a:not([target="_blank"])',selectors:["head > title","#config-diff","#body-wrap","#rightside-config-hide","#rightside-config-show",".js-pjax"],cacheBust:!1,analytics:!1,scrollRestoration:!1});const e=e=>{e&&Object.values(e).forEach((e=>e()))};document.addEventListener("pjax:send",(()=>{btf.removeGlobalFnEvent("pjaxSendOnce"),btf.removeGlobalFnEvent("themeChange");const t=document.body.classList;t.contains("read-mode")&&t.remove("read-mode"),e(window.globalFn.pjaxSend)})),document.addEventListener("pjax:complete",(()=>{btf.removeGlobalFnEvent("pjaxCompleteOnce"),document.querySelectorAll("script[data-pjax]").forEach((e=>{const t=document.createElement("script"),n=e.text||e.textContent||e.innerHTML||"";Array.from(e.attributes).forEach((e=>t.setAttribute(e.name,e.value))),t.appendChild(document.createTextNode(n)),e.parentNode.replaceChild(t,e)})),e(window.globalFn.pjaxComplete)})),document.addEventListener("pjax:error",(e=>{404===e.request.status&&pjax.loadUrl("/404")}))})()</script><script async data-pjax="" src="/config/busuanzi/busuanzi.js"></script><div id="algolia-search"><div class="search-dialog"><nav class="search-nav"><span class="search-dialog-title">搜索</span><button class="search-close-button"><i class="fas fa-times"></i></button></nav><div class="search-wrap"><div id="algolia-search-input"></div><hr><div id="algolia-search-results"><div id="algolia-hits"></div><div id="algolia-pagination"></div><div id="algolia-info"><div class="algolia-stats"></div><div class="algolia-poweredBy"></div></div></div></div></div><div id="search-mask"></div><script src="https://jsd.liiiu.cn/npm/algoliasearch@5.8.1/dist/lite/builds/browser.umd.min.js"></script><script src="https://jsd.liiiu.cn/npm/instantsearch.js@4.75.0/dist/instantsearch.production.min.js"></script><script src="/js/search/algolia.js?v=5.0.0"></script></div></div><div class="needEndHide" id="nav-music"><div id="nav-music-hoverTips" onclick="liuMusic.musicToggle()">音乐已暂停</div><meting-js id="13597135963" server="netease" type="playlist" mutex="true" preload="none" data-lrctype="0" order="random" volume="0.8" api="https://met.liiiu.cn/meting/api?server=:server&amp;type=:type&amp;id=:id&amp;r=:r"></meting-js></div><script data-pjax="">function butterfly_swiper_injector_config(){var a=document.getElementById("recent-posts");console.log("已挂载butterfly_swiper"),a.insertAdjacentHTML("afterbegin",'<div class="recent-post-item" style="height: auto;width: 100%"><div class="blog-slider swiper-container-fade swiper-container-horizontal" id="swiper_container"><div class="blog-slider__wrp swiper-wrapper" style="transition-duration: 0ms;"><div class="blog-slider__item swiper-slide" style="width: 750px; opacity: 1; transform: translate3d(0px, 0px, 0px); transition-duration: 0ms;"><a class="blog-slider__img" onclick="pjax.loadUrl(&quot;posts/4bb33804/&quot;);" href="javascript:void(0);" alt=""><img width="48" height="48" src= "" data-lazy-src="https://p.liiiu.cn/i/2025/04/08/67f49876a62e5.webp" alt="" onerror="this.src=/img/error-page.png; this.onerror = null;"/></a><div class="blog-slider__content"><span class="blog-slider__code">2025-04-08</span><a class="blog-slider__title" onclick="pjax.loadUrl(&quot;posts/4bb33804/&quot;);" href="javascript:void(0);" alt="">PaddleYOLO训练自己的数据集</a><div class="blog-slider__text">近期一直在研究毕业设计，在其中，我涉及到了PaddleYOLO的训练和部署，在网上的教程较少，经过不断努力，我也算是跑出来了，所以在这里分享出来做个记录，防止下次使用又忘记了怎么搞。</div><a class="blog-slider__button" onclick="pjax.loadUrl(&quot;posts/4bb33804/&quot;);" href="javascript:void(0);" alt="">详情       </a></div></div><div class="blog-slider__item swiper-slide" style="width: 750px; opacity: 1; transform: translate3d(0px, 0px, 0px); transition-duration: 0ms;"><a class="blog-slider__img" onclick="pjax.loadUrl(&quot;posts/5f71a4b1/&quot;);" href="javascript:void(0);" alt=""><img width="48" height="48" src= "" data-lazy-src="https://p.liiiu.cn/i/2025/04/27/680dc7916ef34.webp" alt="" onerror="this.src=/img/error-page.png; this.onerror = null;"/></a><div class="blog-slider__content"><span class="blog-slider__code">2025-04-28</span><a class="blog-slider__title" onclick="pjax.loadUrl(&quot;posts/5f71a4b1/&quot;);" href="javascript:void(0);" alt="">耗子面板和DPanel简单体验</a><div class="blog-slider__text">最近毕业设计临近尾声，代码也敲完了，目前就剩稍微的调优，就可以开始写论文啦！在闲暇时间，我也尝试部署了一些不一样的面板程序，总感觉1panel稍微有些复杂，很多功能并用不上，比如GPU，下面简单分享一下我的体验。</div><a class="blog-slider__button" onclick="pjax.loadUrl(&quot;posts/5f71a4b1/&quot;);" href="javascript:void(0);" alt="">详情       </a></div></div><div class="blog-slider__item swiper-slide" style="width: 750px; opacity: 1; transform: translate3d(0px, 0px, 0px); transition-duration: 0ms;"><a class="blog-slider__img" onclick="pjax.loadUrl(&quot;posts/40702a0d/&quot;);" href="javascript:void(0);" alt=""><img width="48" height="48" src= "" data-lazy-src="https://p.liiiu.cn/i/2025/05/06/6819cd4532457.webp" alt="" onerror="this.src=/img/error-page.png; this.onerror = null;"/></a><div class="blog-slider__content"><span class="blog-slider__code">2025-05-07</span><a class="blog-slider__title" onclick="pjax.loadUrl(&quot;posts/40702a0d/&quot;);" href="javascript:void(0);" alt="">本地实现HEXO文章AI摘要</a><div class="blog-slider__text">五一假期结束啦！这五天啥也没干，就在宿舍敲代码，都快无聊死了，恰逢找到了一些免费API，就自己实现一个AI摘要吧！利用API生成摘要文本放在文章头部，再通过hexo进行渲染就好啦！</div><a class="blog-slider__button" onclick="pjax.loadUrl(&quot;posts/40702a0d/&quot;);" href="javascript:void(0);" alt="">详情       </a></div></div><div class="blog-slider__item swiper-slide" style="width: 750px; opacity: 1; transform: translate3d(0px, 0px, 0px); transition-duration: 0ms;"><a class="blog-slider__img" onclick="pjax.loadUrl(&quot;posts/7915ee6b/&quot;);" href="javascript:void(0);" alt=""><img width="48" height="48" src= "" data-lazy-src="https://p.liiiu.cn/i/2025/05/25/6832cc105bc41.webp" alt="" onerror="this.src=/img/error-page.png; this.onerror = null;"/></a><div class="blog-slider__content"><span class="blog-slider__code">2025-05-25</span><a class="blog-slider__title" onclick="pjax.loadUrl(&quot;posts/7915ee6b/&quot;);" href="javascript:void(0);" alt="">数据库可视化WEB工具对比</a><div class="blog-slider__text">最近迁移服务器，并且搞了一个1P专业版玩玩，感觉效果很不错，想找一个管理数据库的服务，其中看了phpmyadmin等一些知名项目，但是都不太符合我的要求，最后经过筛选，找到了比较合适的，分享给大家！</div><a class="blog-slider__button" onclick="pjax.loadUrl(&quot;posts/7915ee6b/&quot;);" href="javascript:void(0);" alt="">详情       </a></div></div><div class="blog-slider__item swiper-slide" style="width: 750px; opacity: 1; transform: translate3d(0px, 0px, 0px); transition-duration: 0ms;"><a class="blog-slider__img" onclick="pjax.loadUrl(&quot;posts/caee2d9f/&quot;);" href="javascript:void(0);" alt=""><img width="48" height="48" src= "" data-lazy-src="https://p.liiiu.cn/i/2025/04/18/68024a618942b.webp" alt="" onerror="this.src=/img/error-page.png; this.onerror = null;"/></a><div class="blog-slider__content"><span class="blog-slider__code">2025-04-18</span><a class="blog-slider__title" onclick="pjax.loadUrl(&quot;posts/caee2d9f/&quot;);" href="javascript:void(0);" alt="">美化你的RSS订阅地址</a><div class="blog-slider__text">近期天天忙着毕业设计，冷落了站点文章的更新，最近也终于算是快要搞完了，于是开始捣鼓一些好玩的东西，在浏览阮一峰大佬的周刊时，了解到了RSS也能美化，折腾了一下，没想到还真实现了，在此分享一下。</div><a class="blog-slider__button" onclick="pjax.loadUrl(&quot;posts/caee2d9f/&quot;);" href="javascript:void(0);" alt="">详情       </a></div></div></div><div class="blog-slider__pagination swiper-pagination-clickable swiper-pagination-bullets"></div></div></div>')}for(var elist="null".split(","),cpage=location.pathname,epage="/",flag=0,i=0;i<elist.length;i++)cpage.includes(elist[i])&&flag++;("all"===epage&&0==flag||epage===cpage)&&butterfly_swiper_injector_config()</script><script defer src="https://jsd.liiiu.cn/npm/swiper@11.1.14/swiper-bundle.min.js"></script><script defer data-pjax="" src="/config/swiper/swiper_init.js"></script><script src="https://jsd.liiiu.cn/npm/live2d-widget@^3.1.3/lib/L2Dwidget.min.js"></script><script>L2Dwidget.init({pluginModelPath:"assets/",model:{scale:1,hHeadPos:.5,vHeadPos:.618,jsonPath:"/live2dw/assets/tororo.model.json"},display:{superSample:2,width:250,height:500,position:"left",hOffset:-20,vOffset:-90},mobile:{show:!1,scale:.5},react:{opacityDefault:.7,opacityOnHover:.2},log:!1,pluginJsPath:"lib/",pluginRootPath:"live2dw/",tagMode:!1})</script></body></html>